cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Partisan
Post Partisan

Deep linking - Mutiple screens

Hi

I had deep linking working, but now I have a requirement to use multiple screens to cater for a longer form, 1 form with 50 columns spans across 5 screens, with only 2 screens ever being used by the users so I decided I would use the patch function along with the updates function.

This is a canvas app and SPO is the data source.

 

The data is written to SPO list, my issue is the email which is sent to the user does not include the ID number, so the user is not directed to the completed form, this is my code on OnSelect of my submit button which sends the email but cant get deep linking to work:

 

Patch(ListName, Defaults(ListName),
 Form1_1.Updates,
 Form1_2.Updates);
Office365Outlook.SendEmailV2(Form1_1.Updates.ApplicantName.Email, "A request has been submitted by " & DataCardValue7_1.Selected.DisplayName, "Form has been submitted <a href='https://apps.powerapps.com/play/MYURL&RefMgt=" & Form1_1.Updates.ID & "'> Link to submitted form </a> ")

 

It worked fine when I was only submitting 1 form:

 

SubmitForm(Form1_3);
Office365Outlook.SendEmailV2(Form1_3.LastSubmit.ApplicantName.Email, "A request has been submitted by  " & DataCardValue7_1.Selected.DisplayName, "form has been submitted <a href='https://apps.powerapps.com/play/MYURL&RefMgt=" & Form1_3.LastSubmit.ID & "'> Link to submitted form </a> ")

 

Also by using the above I could also use the OnSucess property of the form, to alert the user the data had been saved, but using the first function I cannot.

 

Anyone have any ideas ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper III
Helper III

Re: Deep linking - Mutiple screens

Hey G99,

 

Sounds like you are trying to get the ID of the record after patching HOWEVER you are referencing the ID field of the form (which will always be empty if its a new item).

 

To get the ID after the patch, you should wrap the Patch(...) code in an UpdateVariable(...) so you would get something like this:

UpdateContext(
	{
	varPatchedRecord:
	Patch(
		ListName, Defaults(ListName),
		Form1_1.Updates,
		Form1_2.Updates
	);
	}
);
Office365Outlook.SendEmailV2(varPatchedRecord.ApplicantName.Email, "A request has been submitted by " & varPatchedRecord.Selected.DisplayName, "Form has been submitted <a href='https://apps.powerapps.com/play/MYURL&RefMgt=" & varPatchedRecord.Updates.ID & "'> Link to submitted form </a> ")

 Also note that in the Office365Outlook.SendEmailV2() function, we have updated the references to varPatchedRecord rather than the Forms and DatacardValues.


EvanTse

 

View solution in original post

7 REPLIES 7
Highlighted
Helper III
Helper III

Re: Deep linking - Mutiple screens

Hey G99,

 

Sounds like you are trying to get the ID of the record after patching HOWEVER you are referencing the ID field of the form (which will always be empty if its a new item).

 

To get the ID after the patch, you should wrap the Patch(...) code in an UpdateVariable(...) so you would get something like this:

UpdateContext(
	{
	varPatchedRecord:
	Patch(
		ListName, Defaults(ListName),
		Form1_1.Updates,
		Form1_2.Updates
	);
	}
);
Office365Outlook.SendEmailV2(varPatchedRecord.ApplicantName.Email, "A request has been submitted by " & varPatchedRecord.Selected.DisplayName, "Form has been submitted <a href='https://apps.powerapps.com/play/MYURL&RefMgt=" & varPatchedRecord.Updates.ID & "'> Link to submitted form </a> ")

 Also note that in the Office365Outlook.SendEmailV2() function, we have updated the references to varPatchedRecord rather than the Forms and DatacardValues.


EvanTse

 

View solution in original post

Highlighted
Post Partisan
Post Partisan

Re: Deep linking - Mutiple screens

Hi @EvanTse 

 

Thank You.

 

How do I get a message on the screen notifying the user the form has been submitted successfully, as mentioned OnSucess does not work

Highlighted
Helper III
Helper III

Re: Deep linking - Mutiple screens

Hey G99,

To let the user know that have successfully submitted the data.

You can do either:
1. Navigate to another screen that lets them know the submit was successful.
2. Use the notify() function to show a banner at the top letting them know the submit was successful.

Either way, your code would most likely be put after the UpdateContext(...); With a little validation like:
if( Not(Isblank(varSubmittedRecord.ID)), //navigate or notify
)
Highlighted
Post Partisan
Post Partisan

Re: Deep linking - Mutiple screens

Hi @EvanTse 

 

Do both scenarios cater for when the data is not successful though, I recall when I started using PowerApps I did a similar set up, and a reset form function but realised, if the submission was not successful the form would still reset and a notification would still appear?

 

Highlighted
Helper III
Helper III

Re: Deep linking - Mutiple screens

Absolutely!

The main part of the code is the if statement to validate that the data was sent.

To break the code down a bit more:

If(
Not(IsBlank(varSubmittedRecord.ID)),
//Add successful submission code here,
//Add non successful submission code here)

The
"Not(IsBlank(varSubmittedRecord.ID))"

Is checking if there is an ID returned from the patch. If the patch did not work then the ID would be blank which would mean that the false part of the if() function would run.

In my previous post I left out the false part of the statement since we wouldn't do anything, but feel free to add some code in there if you want to do something if the patch didn't work.


Also, if my first reply solved your main issue then can you please mark it as the answer. I think it's a pretty cool bit of code that could help others with the same issue.

Thanks!
EvanTse
Highlighted
Post Partisan
Post Partisan

Re: Deep linking - Mutiple screens

Hi @EvanTse 

 

Apologies for sending you a message via this already answered question but im a little stuck with the next stage of my form. So your solution works like a treat and Thank You.

But now the form is progressing and User1 has submitted the form for review.

User2 comes in and needs to submit a response, and i'm sure how to alter the code to make that form submit. The data has submitted to SPO (i didn't get a notification as i have set that up yet) but rather than updating the same item in SPO, its created a new item and put the data in that, as opposed to updating the current item, here is the code on my save button if you can help please:


SubmitForm(Form1_8);
Office365Outlook.SendEmailV2(Form1_8.LastSubmit.PartA2TR.Email, "created a task for you submitted by " & DataCardValue90.Selected.DisplayName, "Please review the form and complete <a href='https://apps.powerapps.com/play/MyURL&Mgt=" & Form1_8.LastSubmit.ID & "'> Link to submitted form </a> Please complete by" & DataCardValue78.SelectedDate,{Cc:DataCardValue81.Selected.Email & ";" & DataCardValue65.Selected.Email });

 

So changed it to something similar for the previous set up you had advised but but getting loads of red lines and errors with this bit:

UpdateContext(
{
VarPatchedRecord:
Patch(
ListName, Defaults(ListName),
Form1_8.Updates,

)
}
);
If(Not(IsBlank(VarPatchedRecord.ID)),Navigate(SuccessScreen);
Office365Outlook.SendEmailV2(VarPatchedRecord.ApplicantName.Email, "A request has been submitted by " & VarPatchedRecord.ApplicantName.DisplayName & " and Ref number is: " & DataCardValue77.Text, "Part B has been submitted <a href='https://apps.powerapps.com/play/MyURL&Mgt=" & VarPatchedRecord.ID & "'> Link to submitted form </a> "))

 

any ideas?

Highlighted
Helper III
Helper III

Re: Deep linking - Mutiple screens

Hey @G99 ,

UpdateContext({
	VarPatchedRecord:
	Patch(
		ListName, //The list name will need to be changed to your SharePoint List 
                Defaults(ListName), //Change List Name to your SharePoint list name
		Form1_8.Updates,
	)
});
If(
	Not(
		IsBlank(VarPatchedRecord.ID)
	),
	Navigate(SuccessScreen);
	Office365Outlook.SendEmailV2(
		VarPatchedRecord.ApplicantName.Email, 
		"A request has been submitted by " & VarPatchedRecord.ApplicantName.DisplayName & " and Ref number is: " & DataCardValue77.Text, 
		"Part B has been submitted <a href='https://apps.powerapps.com/play/MyURL&Mgt=" & VarPatchedRecord.ID & "'> Link to submitted form </a> "
	)
)

The code I suggested above is pseudo code. You will need to change everything that is highlighted in Red when you copy it to your PowerApp. I have added a few comments to get you started.

 

The main logic that is used to save is the Patch function, here is Microsoft's information on the Patch function.

 

Please note that the Patch() function laid out above will always create a new item rather than update the item.
To update the Item, please read the Modify or Create a record in a data source section of the link above.

 

Let me know if you get stuck with the Patch function.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,621)