Hi there,
Having some issues with LastSubmit variable being passed over to another form that is using a different DataSource.
I have two Datasources and three forms. Two of the forms use the same datasource and the other form uses a different datasource. I set a variable of the first form to get the LastSubmit.ID of that form and then I use that for the other form that uses a different datasource. FormMode = New, a new form is submitted at the Personal Info screen. Then the user continues to fill out the form and depending on their answers, it will either take them to another screen that uses the third form that uses a different datasource OR it will use the answers they submitted in the subsequent screens and put their answers on a form that uses the same datasource as the first submitted form that is housed on its own screen. The problem is, that when the user attempts to enter their information and submit the thrid form, the column I try and match on is being set to 0 instead of the ID of the first submitted form, which should be using the variable that I set on the first SubmitForm button.
**Note I am no longer getting the error message that is in the GIF.**
Here is a link to the GIF workflow for this app.
https://streamable.com/k4seli
Solved! Go to Solution.
Yes, setting the Variable needs to go on OnSuccess - on a new form that is the only way you can catch it other than referring to LastSubmit later on. The rest does not matter.
Can you please send me your email via Private Message - I may be available sometime tomorrow afternoon (my time), so it will be later Monday night for you.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @borowiakn ,
Firstly, can you please consider posting your code as Text - it helps greatly when referring to and correcting it.
The two relevant things out of your screenshots are the properties of MasterID_DataCard1 - the Default
If(
varMode="Edit",
ThisItem.MasterID,
LastContactID
)
and the Update
If(
BrowseGallery1_1.Selected.ID=0,
Value(lastID),
Value(BrowseGalery1_1.Selected.ID)
)
so the two things I initially need to know is when and where you set the Variables LastContactID and lastID.
Also in your animation, I assume this is the "Add Person" button not working? How is this connected to the card above and what is the OnSelect of that button?
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
@WarrenBelz - My sincere apologies, I will be sure to put the code as text.
NextButton.OnSelect
SubmitForm(ScreeningForm);
Reset(Status_Dropdown);
Reset(Reason);
Reset(Type);
Reset(EmergencyContact);
Reset(DatePicker2);
Reset(ProjectName_Dropdown);
Reset(ProjectNumber);
Reset(RoleDropDown);
Reset(PhoneNumber);
Reset(WorkerName);
Reset(CompanyName);
Reset(Emergency_Contact_Number);
Reset(office_jobsite);
Reset(office);
Reset(other_craft_field);
Reset(Non_Clayco_Dropdown);
Set(lastID,ScreeningForm.LastSubmit.ID);
Set(LastContactID,ScreeningForm.LastSubmit.ID);
ResetForm(ScreeningForm);
ResetForm(QuestionsForm);
If(Reason.Selected.ProductName="Travel" || ReasonView.Text= "Travel", Navigate(Travel_Info),Navigate('Screening Questions'));
Set(varMode,"New");
Refresh('[dbo].[COVID_Screening_Form]');
PersonalInfo-Screen.OnVisible (The form I have is on the same page but it is hidden and the fields are being referenced in the form.)
UpdateContext({varNon: "Non-Clayco",varOffice: "Office", varJobsite: "Jobsite"});
Set(statusVar,If(BrowseGallery1_1.Selected.status="true",true,false));
ClearCollect(Role,'[dbo].[COVID_Screening_Form]');
Reset(Status_Dropdown);
Reset(Reason);
Reset(Type);
Reset(EmergencyContact);
Reset(DatePicker2);
Reset(ProjectName_Dropdown);
Reset(ProjectNumber);
Reset(RoleDropDown);
Reset(PhoneNumber);
Reset(WorkerName);
Reset(CompanyName);
Reset(Emergency_Contact_Number);
Reset(other_craft_field);
Reset(office);
Reset(office_jobsite);
ResetForm(ScreeningForm);
If(varMode="Edit",EditForm(ScreeningForm),NewForm(ScreeningForm));
Clear(RecordsCollection);
UpdateContext({showPopup3:false});
Regarding the "Add Person" button, I was using a Patch and Collect statement but was told by Microsoft that it would be easier / better to use a different datasource to store the information that is being entered seperate from the first database and to just reference the first forms ID in a corresponding column on the second database.
AddPersonButton.OnSelect
/*ForAll(
Gallery1.AllItems,
If(IsBlank(MasterID),
Patch(
'[dbo].[COVID_Close_Contact_Form]',
Defaults('[dbo].[COVID_Close_Contact_Form]'),
{
Contact_Name: cc_Name.Text,
Contact_Company: cc_Company.Text,
Contact_Date: cc_Date.SelectedDate,
Contact_Duration: cc_Duration.Text,
Contact_Describe: cc_Describe.Text,
Contact_Created_By: Contact_Created_By,
MasterID: BrowseGallery1_1.Selected.ID
}
),
Patch(
'[dbo].[COVID_Close_Contact_Form]',
{MasterID:MasterID},
{
Contact_Name: cc_Name.Text,
Contact_Company: cc_Company.Text,
Contact_Date: cc_Date.SelectedDate,
Contact_Duration: cc_Duration.Text,
Contact_Describe: cc_Describe.Text,
Contact_Created_By: Contact_Created_By,
MasterID: lastContactID
}
)
));*/
SubmitForm(Contact_Tracing_Form);
Set(
successMessage,
"Contact Successfully added!"
);
Refresh('[dbo].[COVID_Close_Contact_Form]');
Reset(cc_Company);
Reset(cc_Date);
Reset(cc_Describe);
Reset(cc_Duration);
Reset(cc_Name);
Please let me know if you have any other questions and I will do my best to explain what the intended behavior is and what the actual behavior is.
Thanks again!
OK - I will point out something that may be very relevant here - FormName.LastSubmit.ID only works if the user has submitted something in that session - it will not work if you "come back in". Also in Design mode, these things have a habit of being lost when you start changing code.
However is the whole issue the "Add Person" button is not working? In the animation, there was already a tracing record there - where did that come from?
Aside from all of this, you submit the ScreeningForm, and then progress to the screen above which contains the details of possible contacts, with the relevant information at the top (for input) in a form Contact_Tracing_Form, a gallery in the lower section showing all contacts already added and an Add Person button.
You now need the ID of the ScreeningForm to put in the MasterID of the table '[dbo].[COVID_Close_Contact_Form]'
I use this structure on thousands on related sub-lists and the easiest way of getting the ID is to simply put in a hidden card on the ScreenForm (I will call the text box on the card txtID here) and use (put this on the Add Person button
Set(lastID,Value(txtID.Text);
Set(LastContactID,Value(txtID.Text);
You then do not need any of the other logic - the ID will simply be on the form, whether it is a new one or you are editing it.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
@WarrenBelz - Re: In the animation, there was already a tracing record there - where did that come from?
I believe I had already added this record to the gallery so that is why it was showing up.
This is the Filter that is being applied to the items in the gallery:
Gallery1.Items (CloseContact Screen)
Filter('[dbo].[COVID_Close_Contact_Form]',MasterID=BrowseGallery1_1.Selected.ID)
I believe I need to somehow use an If and a Filter function on the Gallery or do a LookUp function. I need to be able to somehow say if this is a new form, then make the FormMode.New and set the MasterID = ContactLastID variable, otherwise FormMode.Edit and set MasterID = BrowseGallery1_1.Selected.ID, right?
If I put the txtID on the ScreenForm, what values am I putting there? Am I changing the default value or anything?
On the ScreenForm.DefaultMode
If(varMode = "Edit", FormMode.Edit,FormMode.New)
I know that there is probably a lot of code that can be removed from the OnVisible and OnSelect buttons happening earlier in the workflow, I currently am just not sure what I can safely remove without it breaking.
Users also need to not only be able to create a NewForm entry but if the Safety Managers need to make an edit to their record, they need to be able to go to a Search screen, perform a search, click on the record, and have it navigate them to the correct record and be able to make any edits to the record as well as save any of their edits. I will try and perform that workflow and upload it here.
@WarrenBelz - Here is the link to the workflow if a user is going to go in and make an edit to a person's record.
https://streamable.com/f5fnyn
The INTENDED behavior would be to ADD the person that I am entering to the Contact Tracing gallery, instead of it overwriting the previous entry. But it is at least adding the user to the Gallery, so I must be doing something halfway correct in terms of the Edit portion. 🙃 So, the effort is getting the NewForm working correctly if the user has JUST submitted a New ScreenForm in a session OR if they are editing the record and navigate to the Contact_Tracing screen and there hasn't been an entry, it needs to set the FormMode of the Contact_Tracing_Form = New, and then use the BrowseGallery1_1.Selected.ID and pass that value over to the MasterID column. And if the user is editing a record from the BrowseGallery1_1.Selected.ID, it needs to check to see if there are any rows (CountRows?) in the Gallery1 found on the Contact_Tracing screen and set the FormMode accordingly, right?
I apologize if I am getting any of this wrong and understand that I am probably making it much more complex than it needs to be. Nonetheless, I appreciate your help with this, I feel like I am FINALLY getting answers on how to do this the correct way.
Lets cover these one at a time - it is very important you understand the concept of this otherwise you will not solve it. Firstly this
Filter('[dbo].[COVID_Close_Contact_Form]',MasterID=BrowseGallery1_1.Selected.ID)
is flawed in New mode as it is showing records from the last item selected in the Gallery (which is not the ID of the one you just created and is why a current record appeared) and adds even more reason for setting the ID from somewhere else.
There is one thing I now realise I left out in relation to my process - where I set the new record ID. I have a global Variable varID, (you can use your lastID) which always reflects the ID of the current record being worked on. I now have a better idea for you than the hidden field (forget that one). On the OnSelect of BrowseGallery1_1
Set(lastID,ThisItem.ID)
On the OnSuccess of ScreenForm
Set(lastID,Self.LastSubmit.ID)
The Items of your Gallery
Filter('[dbo].[COVID_Close_Contact_Form]',MasterID=lastID)
One other important thing here - you are using SubmitForm() for the Contact_Tracing_Form, so the value of lastID needs to be on the form.
It will then add the current ID in the field MasterID of your data table '[dbo].[COVID_Close_Contact_Form]' Once you have done all of this, you do not need any other logic - lastID will always be either what you have selected from the gallery or what you just created.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
@WarrenBelz - I am tracking everything you are saying and I've taken the liberty to show you all of the OnSelect properties of the buttons found within the BrowseGallery1_1.
Here are the OnSelect functions happening in the BrowseGallery1_1:
.OnSelect
Select(Parent);
If(CountRows(Gallery1.AllItems)=0,Set(varMode,"New"),Set(varMode,"Edit"));
Navigate(Contact_Tracing,ScreenTransition.Fade);
Set(varButton, true);
Set(lastID,ThisItem.ID)
.OnSelect
Set(varMode,"Edit");
Set(lastID,ThisItem.ID);
If(Reason.Selected.ProductName = "Travel" || ReasonView.Text= "Travel", Navigate(Travel_Info),Navigate('Screening Questions'));
.OnSelect
Select(Parent);
Set(varMode,"Edit");
Set(lastID,ThisItem.ID);
Navigate('Personal Info',ScreenTransition.Fade);
Set(varButton, true)
I am confused about your last bit about "adding the MasterID of my data table '[dbo].[COVID_Close_Contact_Form]' ".
I already have the MasterID on the form. The values at the top are just free-floating Text Input boxes that are then being referenced in the Contact_Tracing_Form. (See
Hopefully, this helps paint a clearer picture of what all is happening with my app. Much appreciated for your hasty replies and super helpful concept explanations!
I think we need to tackle one issue at a time - can we please put everything else including related code aside.
The fundamental thing I see is you need to create records in your table '[dbo].[COVID_Close_Contact_Form]' which has a field MasterID that matches the corresponding ID in your table '[dbo].[COVID_Screening_Form]'.
You simply need to always have the value of the second (ID) available so that you can either:-
Firstly, is this all correct and have you also set the lastID on the OnSuccess of the main form?
@WarrenBelz - I applied all of the changes to my app. I performed UAT by PLAYING the app instead of performing the UAT in Edit Mode of the app with the new changes and here is what has happened so far:
1. New Form > Fill out fields in Personal Info Screen > Submit > ScreeningForm is submitted Successfully. ✔️
(Confirmed validation as I receive an email notifying me that it has been successfully submitted)
2. Continue onto the QuestionsForm > Fill out fields in the corresponding fields that DO NOT take me to the Contact Tracing Screen > Submit > QuestionsForm is submitted successfully. ✔️
3. Navigate to BrowseGallery1_1 > Selected previously entered record by selecting & > Confirmed that Fields are showing previously entered values on both previously submitted QuestionsForm & ScreeningForm. ✔️
4. From the BrowseGallery1_1 > Selected previously entered record by selecting > Contact_Tracing Screen > Entered info in fields to create New Contact > Selected Add Person > Person was added to Gallery1. ✔️
5. Went to the BrowseGallery1_1 again > Selected > Contact_Tracing Screen > Gallery1 shows previously entered person > Entered info in fields to create New Contact > Selected Add Person > Person replaced previously entered person in Gallery1. ✖️
6. New Form > Fill out fields in Personal Info Screen > Submit > ScreeningForm is submitted Successfully ✔️ > Continue onto the QuestionsForm > Fill out fields in the corresponding fields that DO take me to the Contact Tracing Screen > Gallery1 is showing previously entered person in Gallery1 from 5. ✖️
6a. Entered info in fields to create New Contact > Selected Add Person > Person entered replaced entered person in Gallery1 > Selected Submit & Next Page > Entered information into final Quarantine Screen > Select Submit > QuestionsForm is submitted > Navigate to BrowseGallery1_1 and Selected previously entered record by selecting , Previous entry is not showing up > Select Back > Navigate to BrowseGallery1_1 and Selected previously entered record from 4 > Previous entry is showing up in Contact Tracing screen in the Gallery1.
I see multiple issues that are happening.
ISSUE: In 5, if the user tries to submit more than one person, the person is getting overwritten.
PROPOSED SOLUTION: I believe that is because I have code on the Contact_Tracing_Form.OnSuccess that needs to be removed, that is as follows:
Set(varMode , "New");ResetForm(Self)
In 6, it is pulling in the previously entered person in Gallery1 but not sure what I need to do in order to fix that.
I know that I need to stay focused on just ONE thing, but I am unable to do that because there are multiple paths that lead you in different directions, so I am just trying to be thorough.
Thank you @WarrenBelz again and looking forward to your reply.
Dear Community Members, We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd. During this period, members will not be able to Kudo, Comment, or Reply to any posts. On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities. What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!
We are excited to announce the Summer of Solutions Challenge! This challenge is kicking off on Monday, June 17th and will run for (4) weeks. The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities. Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”) - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024 Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods. You must enter into each weekly Entry Period separately. How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different. Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers. At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing. Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner. A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random. Individuals will be contacted before the announcement with the opportunity to claim or deny the prize. Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners. Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event. ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE** Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08 23 @WarrenBelz 31 @DBO_DV 10 @Amik 19 AmínAA 6 @mmbr1606 12 @rzuber 4 @happyume 7 @Giraldoj 3@ANB 6 (tie) @SpongYe 6 (tie) Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08 10@WarrenBelz 25 @DBO_DV 6@mmbr1606 14 @AmínAA 4 @Amik 12 @royg 3 @ANB 10 @AllanDeCastro 2 @SunilPashikanti 5 @Michaelfp 2 @FLMike 5 @eduardo_izzo 2 Meekou 2 @rzuber 2 @Velegandla 2 @PowerPlatform-P 2 @Micaiah 2 Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27 Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8 SunilPashikanti8
On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners. The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights. Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.
We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for. We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer. Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together. Here's to new beginnings and endless possibilities! If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport. To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages