cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Panoone
Frequent Visitor

Strange problem with LastSubmit

Hi all,

I hope you can help me out. This has been driving me crazy!

I have a SharePoint list form which I've customised in PowerApps.

I have a choice field called Status with the following values:

New
Awaiting Approval
Approved
Provisioned

I have a button that checks the status and submits the form. e.g.

 

 

If(Status_DataCardValue.Selected.Value = "New",
Notify("A notification has been sent to " & Manager_DataCardValue.Selected.DisplayName & ".");
SubmitForm(SharePointForm1),
If(Status_DataCardValue.Selected.Value = "Awaiting Approval",
...))

 

 

In the OnSuccess event I check the value of the LastSubmit value of the Status and perform various actions, such as send an email and patch the Status field to its next value.

 

 

If(
	SharePointForm1.LastSubmit.Status.Value = "New",
	Office365Outlook.SendEmailV2(SharePointForm1.LastSubmit.Manager.Email,
	"User Onboarding: Approval Request for " & SharePointForm1.LastSubmit.'Display Name',
	"<p>Dear " & SharePointForm1.LastSubmit.Manager.'Display Name' & ",</p>" &
    "<p>Please click the link below to view and approve the onboarding of this user.</p>" &
    "<p>Link to item: <a href=""" & Left(SharePointForm1.LastSubmit.'{Link}',Find("_layouts",SharePointForm1.LastSubmit.'{Link}')-1) & SharePointForm1.LastSubmit.'{Path}' & "EditForm.aspx?ID=" & SharePointForm1.LastSubmit.ID & """>View in SharePoint</a></p>"...;
Patch(
        'User Onboarding',
        {ID: SharePointForm1.LastSubmit.ID},
        {Status:{
            '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            Value:"Awaiting Approval"
            }
        }
    ),...

 

 

Everything works flawlessly except with the NewForm. The email that is received contains the correct Link to the Item (i.e. Link, Path and ID) but all the other LastSubmit.Column values are from another form -- even if I delete all previous records!

I don't understand how some values can be correct (the ID) but the others reference a different list item. All subsequent form submissions from the EditForm work as expected. It's almost like there's a delay with new items whereby the ID is immediately available but the complete record is yet to be available.

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @Panoone ,

 

Here is a workaround that save the last submitted record to variable upon the last submit ID at first, and then replace the  SharePointForm1.LastSubmit.ColumnName by Variablename.ColumNname to reference other values.

Set(varRecord, LookUp('SP list',ID=SharePointForm1.LastSubmit.ID));
If(
	VarRecord.Status.Value = "New",
	Office365Outlook.SendEmailV2(VarRecord.Manager.Email,
	"User Onboarding: Approval Request for " & VarRecord.'Display Name',
	"<p>Dear " & VarRecord.Manager.'Display Name' & ",</p>" &
    "<p>Please click the link below to view and approve the onboarding of this user.</p>" &
    "<p>Link to item: <a href=""" & Left(VarRecord.'{Link}',Find("_layouts",VarRecord.'{Link}')-1) & VarRecord.'{Path}' & "EditForm.aspx?ID=" & VarRecord.ID & """>View in SharePoint</a></p>"...;
Patch(
        'User Onboarding',
        {ID: VarRecord.ID},
        {Status:{
            '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            Value:"Awaiting Approval"
            }
        }
    ),...

 

Hope this helps.

Sik 

View solution in original post

2 REPLIES 2
v-siky-msft
Community Support
Community Support

Hi @Panoone ,

 

Here is a workaround that save the last submitted record to variable upon the last submit ID at first, and then replace the  SharePointForm1.LastSubmit.ColumnName by Variablename.ColumNname to reference other values.

Set(varRecord, LookUp('SP list',ID=SharePointForm1.LastSubmit.ID));
If(
	VarRecord.Status.Value = "New",
	Office365Outlook.SendEmailV2(VarRecord.Manager.Email,
	"User Onboarding: Approval Request for " & VarRecord.'Display Name',
	"<p>Dear " & VarRecord.Manager.'Display Name' & ",</p>" &
    "<p>Please click the link below to view and approve the onboarding of this user.</p>" &
    "<p>Link to item: <a href=""" & Left(VarRecord.'{Link}',Find("_layouts",VarRecord.'{Link}')-1) & VarRecord.'{Path}' & "EditForm.aspx?ID=" & VarRecord.ID & """>View in SharePoint</a></p>"...;
Patch(
        'User Onboarding',
        {ID: VarRecord.ID},
        {Status:{
            '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            Value:"Awaiting Approval"
            }
        }
    ),...

 

Hope this helps.

Sik 

Thanks @v-siky-msft . That's the path I ended up taking and seems much more reliable, especially in the presence of patches occurring.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,516)