web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Data not saved to SPO
Power Apps
Answered

Data not saved to SPO

(0) ShareShare
ReportReport
Posted on by 1,625

Hi I seem to be a little lost.

I have a canvas app, with SharePoint Online as my data source.

I have the following code on my OnSelect property of my save button:

If(
!IsBlank(DataCardValue28.Selected)
Or !IsBlank(DataCardValue20.Selected)
Or !IsBlank(DataCardValue19.SelectedDate),
SubmitForm(Form1Approval),
Notify("You need complete the form by including your name, approve or reject and date ", NotificationType.Error, 3000)
)

On the OnSuccess of the form

If(DataCardValue20.Selected.Value = "Rejected", Office365Outlook.SendEmailV2(Form1Approval.LastSubmit.YourName.Email, "A request has been " & DataCardValue20.Selected.Value & "by" & CurrentUser.FullName, "Please review <a href='https://apps.powerapps.com/play/URL&T=" & Form1Approval.LastSubmit.ID & "'> Link to submitted form </a> "));

If(DataCardValue20.Selected.Value = "Approved", Office365Outlook.SendEmailV2(Form1Approval.LastSubmit.HolderName.Value, "A request has been " & DataCardValue20.Selected.Value & "by" & CurrentUser.FullName, "Please review the form and approve/reject <a href='https://apps.powerapps.com/play/URL&T=" & Form1Approval.LastSubmit.ID & "'> Link to submitted form </a> ",{Cc:CurrentUser.Email & ";" & DataCardValue28.Selected.Email}))

I was getting an error to do with the To when i attempted to save the data, so I have // both the functions on the OnSuccess but now the little ants go past on the screen, but going back to SharePoint the data isnt written back. Anyone know where to start or how to resolve this?

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @Lefty ,

    Firstly, the logic of your save seems wrong if you need to fill out all three values, but this will not affect the save (or is your issue here)- the logic should be And, not Or

    If(
     !IsBlank(DataCardValue28.Selected) && 
     !IsBlank(DataCardValue20.Selected) &&
     !IsBlank(DataCardValue19.SelectedDate),
     SubmitForm(Form1Approval),
     Notify(
     "You need complete the form by including your name, approve or reject and date ", 
     NotificationType.Error, 3000
     )
    )

    Your OnSuccess code should not affect the save as long as it is valid as it happens after the SubmitForm.

    You can do a bit of trouble shooting here - firstly, copy your OnSuccess code somewhere and then delete it and see if it saves.

    If it does not do the same for the save and leave just SubmitForm there. I can then I can help you to isolate what the issue is.

     

    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 Profile Picture
    156,528 Most Valuable Professional on at

    @Lefty ,

    UPDATE

    You had some commas in the wrong place in your OnSuccess - you might try this after the other tests

    Office365Outlook.SendEmailV2(
     Form1Approval.LastSubmit.YourName.Email, 
     "A request has been " & DataCardValue20.Selected.Value & 
     "by" & CurrentUser.FullName & 
     Switch(
     DataCardValue20.Selected.Value,
     "Rejected",
     "Please review <a href='https://apps.powerapps.com/play/URL&T=" & 
     Form1Approval.LastSubmit.ID & "'> Link to submitted form </a> ",
     "Approved", 
     "Please review the form and approve/reject <a href='https://apps.powerapps.com/play/URL&T=" & 
     Form1Approval.LastSubmit.ID & "'> Link to submitted form </a> ",
     {Cc:CurrentUser.Email & ";" & DataCardValue28.Selected.Email}
     )
    )
  • Lefty Profile Picture
    1,625 on at

    Hi @WarrenBelz 

     

    Firstly thank you for your help.

    I have changed my code to reflect yours and it appears prior to asking the question here there was data being written back to the SharePoint list, but not all of the data (maybe it is to do with the fact the fields are dropdowns in SharePoint, but the information coming from PowerApps I have changed via a ComboBox, and it appears only that data isn't written back to the SP list).
    Based on that (which i will need to tackle) i guess i don't need to suss out the SubmitForm as that appears to be writing back to SP but OnSuccess does not trigger, as I am not sent an email nor am I navigated to a SuccessScreen (which is part of the OnSuccess).

    I've changed the code on my Save button to only SubmitForm, again the data is written to SP but not the combobox, and the OnSuccess does not trigger, any further help troubleshooting will be appreciated.

  • Lefty Profile Picture
    1,625 on at

    HI @WarrenBelz 

    I thought i would reply to this separately.

    I attempted to use your code, but got lost around :

    Link to submitted form </a> ",
     "Approved", 

    The email and recipients depend on the value of it being approved or rejected, which i'm sure you already know. But I could not see the 'To' being different, if its rejected it needs to go to user1, but if its approved it needs to go to approver2.

     

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    OK @Lefty ,

    If your OnSuccess is not triggering, then something is not writing back. Look at the Update property of the offending card/s - if you have changed a control, you may have to change this to suit.

     

    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.

  • Lefty Profile Picture
    1,625 on at

    Hi @WarrenBelz 

     

    I've deleted the data card I had changed, and added in the original, without changing any of the update properties, this now seems to save back to SharePoint list, my OnSuccess is triggering it seems as I got an approved email but the code I have on my OnSuccess is missing '(' or ')' but can't spot it, I've used your code but have missed something, and i've added in a navigate to sucess screen which does not trigger:

    Office365Outlook.SendEmailV2(
     Form1Approval.LastSubmit.YourName.Email,
     "A request has been " & DataCardValue20.Selected.Value & "by" & CurrentUser.FullName & 
     Switch(
     DataCardValue20.Selected.Value, 
     "Rejected", 
     "Please review the form <a href='https://apps.powerapps.com/play/URL&T=" & Form1Approval.LastSubmit.ID & "'> Link to submitted form </a> ",
     "Approved", "You have been identified as the approver. <br> Please review the form <a href='https://apps.powerapps.com/play/URL&T=" & Form1Approval.LastSubmit.ID & "'> Link to submitted form </a> ",{Cc:CurrentUser.Email & ";" & DataCardValue28.Selected.Email});
    Navigate(SuccessScreen)

    Here are the 2 errors. hopefully you can help:

    Parenclose.PNG

    and the other:

    Parenclose1.PNG

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Thanks @Lefty ,

    Please see below - if you want to debug code, try parsing it as below and you will generally spot the issue. I have not got the advantage of seeing errors as they occur and have free-type this, but I think I found it in the cc area of the second mail.

    Office365Outlook.SendEmailV2(
     Form1Approval.LastSubmit.YourName.Email,
     "A request has been " & DataCardValue20.Selected.Value & "by" & CurrentUser.FullName & 
     Switch(
     DataCardValue20.Selected.Value, //criteria
     "Rejected", //Choice 1
     "Please review the form <a href='https://apps.powerapps.com/play/URL&T=" & 
     Form1Approval.LastSubmit.ID & "'> Link to submitted form </a> ",
     "Approved", //Choice 2
     "You have been identified as the approver. 
     <br> Please review the form <a href='https://apps.powerapps.com/play/URL&T=" & 
     Form1Approval.LastSubmit.ID & 
     "'> Link to submitted form </a> ",
     {
     Cc:" & //an error was in here
     CurrentUser.Email & 
     ";" & 
     DataCardValue28.Selected.Email
     }
     )
    );
    Navigate(SuccessScreen)

     

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard