cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jvdlinden
Level: Powered On

SubmitForm and Navigate does not update Attachments in details form

Dear all,

 

I'm facing an issue with Attachments.

 

Let me first just simply explain how my app works.

 

There are two data sources:

  1. Declarations
  2. Expenses

Both are SharePoint Online custom lists.

 

The purpose of this app: the end user can create a new declaration for i.e. a business trip. That would be the first step, to create a declaration (trip) and fill in the information (country of visit, reason of visit etc.).

 

Next, the end user will add one or more expenses to this declaration. The end user fills in a form:

New-Expense.png

 

In this form, the user tells about the costs incurred and attaches a file (a photo of the receipt(s)). This is the recently rolled-out Attachments feature.

 

So far so good.

 

But now, the user is also able to delete a photo (attachment) from a different screen. When the user taps the delete icon, the OnSelect is:

 

SubmitForm(DeleteReceiptScreen_FORM_Attachments); Patch(Trips,SelectedTripRecord,{SubItemsLastModified: Text(Now())}); Navigate(ExpenseDetailsScreen,ScreenTransition.Fade); Refresh(Expenses_1); Refresh(Trips)

 

The user will automatically navigate back to the details screen of the expense.

There the attachment which has been deleted will still remain visible. Until the user switches screens (back and forth).

 

 

When the users selects an expense, to view its details, I use the following OnSelect code:

Set(SelectedExpenseRecord,ThisItem);Navigate(ExpenseDetailsScreen,ScreenTransition.Fade,{displayItem:ThisItem})

As you can see in the code, I set the expense as a global variable.

 

 

When the user navigates back from the Receipt Delete screen, it shows the right expense details because the Item property of the form is set to SelectedExpenseRecord. The only thing is, the single attachment which has been deleted from does not seem to be removed from the form straight after navigation. Even a refresh of the data source (automatically or manually) does not resolve this issue. Only switching screens does.

 

Now, I hope that someone else is also facing this issue, and might help me out here.

 

I have also raised an SR for this issue with the PowerApps Support team, but they couldn't find a solution so far. If they do, I will post the solution here. And vice versa of course.

 

Thanks for your help!

1 REPLY 1
jvdlinden
Level: Powered On

Re: SubmitForm and Navigate does not update Attachments in details form

I did receive a reply from the Support team.

 

The change necessary would be to include the following code in the OnSuccess property of the Form that removes the attachment:

Set(SelectedExpenseRecord,LookUp(Expenses_1,ID=DeleteReceiptScreen_FORM_Attachments.LastSubmit.ID))

 

The LookUp seems to be the key to make this work.

 

Does this make sense? I can't figure out why this should work.

I will definitely try this out.