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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / LastSubmit issue - ima...
Power Apps
Answered

LastSubmit issue - image URL on profiles app

(0) ShareShare
ReportReport
Posted on by

I have a profiles app using a SharePoint list (StudentProfiles) as the data source. 

User adds their info to a new form (Form4) and uploads an image to the attachment field (PhotoPix is the named value).

OnSelect of the Save button is:

UpdateContext({PicName: First(PhotoPix.Attachments.Name).Name});SubmitForm(Form4);
UpdateContext ({LastProfile: Last (StudentProfiles)})

 

OnSuccess of Form4 is: 

Refresh (StudentProfiles); UpdateIf (StudentProfiles, ID = Form4.LastSubmit.ID, {ImageURL: Concatenate("https://sitename/Lists/StudentProfiles/Attachments/", Text(LastProfile.ID), "/",PicName)})

 

So basically, after the form has been submitted the SharePoint list refreshes and ImageURL field is updated with the URL to the attachment. 

Most of the time this works, but sometimes the wrong list item is updated with the picture name. For example, if I have submitted a form with ID 2, the on success formula will update ID 1 with the picture from ID 2. Therefore, the image won't display, and will stop displaying the right image for ID 1 as well. It's like it's not picking up on the last submitted form, but the one before then.

 

Is there anything I can change to make this more reliable?

 

 

Categories:
I have the same question (0)
  • Verified answer
    CU-18081211-6 Profile Picture
    9,270 Moderator on at

    Hi @Anonymous,

     

    I think that the main reason for your problem is settled here :

     

    SubmitForm(Form4);

    UpdateContext ({LastProfile: Last (StudentProfiles)})

     

    The execution of the command SubmitForm(Form4) is not finished when UpdateContext ({LastProfile: Last (StudentProfiles)}) command is started/finished and so the result can not be as expected all the time (getting the last value  from StudentProfiles before the submitform is finished).

    To solve it, move the update context ({LastProfile:....})after refresh() on success property when you are sure that the record is created.

     

    Also I guess is wise to replace UpdateIf function with Patch function as follow, because the function you use iterates between all the records of StudentProfiles list (this will have an negative impact on app performance when you work with large lists):

     

    Refresh (StudentProfiles); Patch (StudentProfiles, LookUp(StudentProfiles,ID = Form4.LastSubmit.ID), {ImageURL: Concatenate("https://sitename/Lists/StudentProfiles/Attachments/", Text(LastProfile.ID), "/",PicName)})

     

    Hope it helps !

     

        

     

  • Community Power Platform Member Profile Picture
    on at

    Thank you @gabibalaban . This seemed to work for a while but I am still getting this issue. The LastSubmit ID is coming up as the ID of the one that had submitted before the last one.

     

    Now I have OnSelect of the Save button: UpdateContext({PicName: First(PhotoPix.Attachments.Name).Name});SubmitForm(Form4); Navigate(StudentGallery,ScreenTransition.Cover)

    OnSuccess of Form4: Refresh (StudentProfiles); UpdateContext ({LastProfile: Last (StudentProfiles)}); Patch (StudentProfiles, LookUp(StudentProfiles,ID = Form4.LastSubmit.ID), {ImageURL: Concatenate("https://sitename/Lists/StudentProfiles/Attachments/", Text(LastProfile.ID), "/",PicName)})

     

    As an alternative, could I perhaps save the submitted ID as a context and use that in the concatenate of the URL?

    I am looking for the most reliable option.

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard