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?