cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shnurich
Helper III
Helper III

Custom form opening created item

Hi

 

Have an issue:

Sharepoint Custom form, I would like to create new item:
Patch function & Run flow, get response , and open this item and refresh it with updates from flow.

But form dont upload updated item after flow and works only after page refreshing. Form dont open created item.

Please help to fix it!

My OnSelect Button code:

If(SharePointForm1.Mode=New;

ClearCollect(MyPatchedRecords; Patch(List; Defaults(List);{Title:DataCardValue41.Text}) ;; 
UpdateContext({Mode_Edit: true}) ;;
Set(RefreshVar; 'Process (PowerApps)'.Run(Value(First(MyPatchedRecords).ID);Var1;Var2).refresh) ;;
If(RefreshVar="refresh";Refresh(List)) ;;
Set(RefreshVar;"false");

Patch(List;LookUp(List;ID=Value(DataCardValue10.Text));{Title:DataCardValue41.Text}))

My sharepointForm1 Item:
If(Mode_Edit=true;First(MyPatchedRecords);SharePointIntegration.Selected)

DefaultMode: FormMode.Edit

1 ACCEPTED SOLUTION

Accepted Solutions
v-albai-msft
Community Support
Community Support

Hi @shnurich ,

What do you want to display inside your form?

What is the function of your flow? Does it update values of your newly created item? If I misunderstand, please provide more detailed information about your scenario so that I can better understand your problem.

If yes, do you mean that after flow running, the item gets updated, but the values inside form do not get updated?   

Based on your description, I do a simple test in my side and find a workaround using another refresh button:

(I update the list item manually, this has a same result of using a flow to update list item)

1. Create a custom form with Patch button and Refresh button(we need to use the second Refresh button to make the form get the updated value, we cannot put all these functions inside one button):

Patch(list1,Defaults(list1),{Title:DataCardValue1.Text});Set(TheID,First(SortByColumns(list1,"Modified",SortOrder.Descending)).ID);UpdateContext({Mode_Edit: true}); Refresh(list1)

Note: You can see in my this formula, after Patch(), I use Set() function to save the new added item into a variable, so that I can directly use this variable in the form’s Item property.  

v-albai-msft_0-1613559676904.png

For Refresh button, you must add a Refresh() function and an EditForm() function as below, otherwise, my function will not work:

v-albai-msft_1-1613559676908.png

Then set Item property of form to below. This is because collection cannot be recognized outside PowerApp, so I cannot save new created item into a collection.

If(Mode_Edit=true,LookUp(list1,ID=TheID),SharePointIntegration.Selected)

v-albai-msft_2-1613559676912.png

2. Create a new item called “0217” using Patch button. Then instead of using a flow, I open this list in another page and update the “Title” value manually, rename it to “0217A”. Then go back to the first page and click Refresh button in the form. You can see below, values inside form also get changed after click Refresh button.

v-albai-msft_3-1613559676914.png

Note: After apply above method, after you close the form and want to create another new list item, the title column will auto have a value(Last updated Item’s value). You need to manually remove the value or you can also add a button to reset the Title control.

Best Regards,

Allen

View solution in original post

3 REPLIES 3
shnurich
Helper III
Helper III

Please hepl! 🙂 

 

v-albai-msft
Community Support
Community Support

Hi @shnurich ,

What do you want to display inside your form?

What is the function of your flow? Does it update values of your newly created item? If I misunderstand, please provide more detailed information about your scenario so that I can better understand your problem.

If yes, do you mean that after flow running, the item gets updated, but the values inside form do not get updated?   

Based on your description, I do a simple test in my side and find a workaround using another refresh button:

(I update the list item manually, this has a same result of using a flow to update list item)

1. Create a custom form with Patch button and Refresh button(we need to use the second Refresh button to make the form get the updated value, we cannot put all these functions inside one button):

Patch(list1,Defaults(list1),{Title:DataCardValue1.Text});Set(TheID,First(SortByColumns(list1,"Modified",SortOrder.Descending)).ID);UpdateContext({Mode_Edit: true}); Refresh(list1)

Note: You can see in my this formula, after Patch(), I use Set() function to save the new added item into a variable, so that I can directly use this variable in the form’s Item property.  

v-albai-msft_0-1613559676904.png

For Refresh button, you must add a Refresh() function and an EditForm() function as below, otherwise, my function will not work:

v-albai-msft_1-1613559676908.png

Then set Item property of form to below. This is because collection cannot be recognized outside PowerApp, so I cannot save new created item into a collection.

If(Mode_Edit=true,LookUp(list1,ID=TheID),SharePointIntegration.Selected)

v-albai-msft_2-1613559676912.png

2. Create a new item called “0217” using Patch button. Then instead of using a flow, I open this list in another page and update the “Title” value manually, rename it to “0217A”. Then go back to the first page and click Refresh button in the form. You can see below, values inside form also get changed after click Refresh button.

v-albai-msft_3-1613559676914.png

Note: After apply above method, after you close the form and want to create another new list item, the title column will auto have a value(Last updated Item’s value). You need to manually remove the value or you can also add a button to reset the Title control.

Best Regards,

Allen

Thanx!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,275)