Hi Everyone!
So I have a screen that shows details of a gallery item, data points to a SharePoint list. I have a form that just has an attachment card that defaults to View.Attachment (View is the 'ThisItem' from the gallery screen before this details screen). It prepopulates the attachments on the list item I am viewing. I created an add attachment button with a pop up screen to add the attachment and save which runs a power automate that takes the attachment and adds it to the shareoint list. Everything works fine!
What I cannot figure out is after I add my attachment I cannot for the life of me figure out how to refresh my attachment card so the new attachment shows up. I've tried resetform where the card lives, refreshing the data itself, nothing is working. If i click the back button and go back into that screen the attachment is there (also verified in sharepoint list) so its just a UI refresh issue!!
I've also tried just pulling the attachment data card out of the form and just having it display on the screen and refreshing that, still nothing. Please help!!!
So it did work the way I had it, it was able to update and add more attachments to the sharepoint list item via power automate, just wouldnt refresh. I do not think there is a fix to be honest because the control for the form attachment card is to load the data after selecting it from the gallery and you cant do a hard reset on the information without screen reloading (go back and go back in again).
The fix was to completely rework how I manage attachments. I removed the form attachment card from the form and made a standalone control for the attachments (copy the card from the form and paste it outside of the form). I then created a new document library in sharepoint to store attachments and then updated my power automate to take the attachments and drop them in there based on the ID. In my recall to view the attachments and add more later, I added a gallery to view all the attachments, matching on that ID, and now because it was a gallery pointing to a data source (document library) when I refreshed it works!
Thanks for the assistance and I hope this helps anyone out there who was trying to do it the first way.
@Nicci wrote:
Hey Bryan,
Ok so my form is now set to edit and the Item = View (which is the variable from gallery) and the attachment card is parent.default for the display mode. The issue with Edit mode is it has an 'attach file' button and the ability to click X to try to remove but no way to save, the way I'm doing it is a pop up box to then add new attachments but I dont want people to try and remove attachments which is why the card was set to view even though the form was edit. Either way good enough for now to test. However after adding the new attachment it's the same issue. Refreshing forms/data is still not refreshing that box to show the new attachment.
Its a power automate that adds the attachment file content directly to the sharepoint list in the attachment column.
It sounds like you are mixing up two methodologies for handling files in SharePoint. The attachment control is fully capable of attaching files to the SharePoint list items, but it will only do this upon SubmitForm() being called. You are right that the attachments could be deleted by a user easily. The attachment control does not upload or delete files in real time -- no action occurs until SubmitForm() is called. An alternative is a stand-alone SharePoint doc library that references the ID of your list item in a many-to-one fashion.
To help your form work a bit better and respond to changes to the list, consider replacing the Item property with a LookUp() instead of simply a variable. The variable doesn't change unless the app specifically changes it; the LookUp() will respond to refreshes and changes of the underlying data source. It will look something like:
LookUp(myDataSource, ID = View.ID)
Bryan
Hey Bryan,
Ok so my form is now set to edit and the Item = View (which is the variable from gallery) and the attachment card is parent.default for the display mode. The issue with Edit mode is it has an 'attach file' button and the ability to click X to try to remove but no way to save, the way I'm doing it is a pop up box to then add new attachments but I dont want people to try and remove attachments which is why the card was set to view even though the form was edit. Either way good enough for now to test. However after adding the new attachment it's the same issue. Refreshing forms/data is still not refreshing that box to show the new attachment.
Its a power automate that adds the attachment file content directly to the sharepoint list in the attachment column.
Your method 2 above is the better path - you need an edit form control to do this.
I suggest leaving the DisplayMode of each card within the form as "Parent.DisplayMode". That way, if you want your form to create new records each time SubmitForm() is used, you set its default mode to New and ResetForm() will put it back in FormMode.New each time. However, if you are trying to see what attachments have been uploaded to an existing item, then your form must be in FormMode.Edit and the Item property must contain a reference to the record you want to show/edit.
I am a little confused by how you are doing your attachments. Are you attaching files directly to the item in the SharePoint list using the attachment control? Or, are you using a Power Automate flow to place files in a separate document library that references back to the SharePoint list item?
Hi Bryan!
Ok so the form data source is the name of my datasource and I am refreshing that after saving a new attachment. I tried 2 different methods with no success:
1. The form is a formviewer, the item is set to 'View' which is a variable set from the gallery to = ThisItem which just the attachment card there. Doing it this way I cannot reset the actual form because its a form viewer. It shows the list of attachments, but does not update unless I leave and come back to the screen.
2. I created a regular form (not form viewer), pointing the data source to the sharepoint list and set the mode to 'new' and added the attachment card to it. The attachment card display mode is set to 'new' and I defaulted the attachment card Items = View.Attachment. It shows the attachment, does not refresh when i reset the form, but works if I leave and come back.
I'm hoping I explained this right! Thank you!
Do you have some sort of record reference in the Item property of the form? If so, check to make sure that is getting renewed when an attachment is added.
If that isn't the issue, please share details of what is in the Items & Item property of the form, and Default property of the attachment card and we'll help you troubleshoot further.
Hope that helps,
Bryan
WarrenBelz
146,605
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,946
Most Valuable Professional