cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fpc-kdrosario
Helper I
Helper I

Updating a field from the record selected from a gallery having a collection as its source.

Good day humans,

 

I have this form that could let the user save drafts and submit forms.

So at the beginning, the user creates a form and saves it as either draft or completed offline form.

The form has 2 buttons, "Save Draft" and "Submit Form Offline".

So on both buttons, I placed on the OnSelect part the logic to save the form in a collection:

 

coll_Form,
{
    FORM_STATUS: "Completed",
    CREATED_DATE: Now(),
    CREATED_BY: User().Email,
    x_group: arrGMGroup.Selected.keyvalue,
    x_plantation: arrPlantation.Selected.keyvalue
}

 

For the FORM_STATUS, it is "Completed" when the "Submit Form Offline" is pressed, while it is "Draft" when the "Save Draft button is pressed.

 

Now that it's saved on the collection, I've created a gallery to show the records of the collection and can be filtered by either "Completed" or "Draft" FORM_STATUS.

 

Now, when a user opens a form with "Draft" FORM_STATUS, he can edit the form.

This edit form has also the same 2 buttons, "Save Changes on Draft" and "Save Form as Complete".

The thing is, I don't know how to change the "FORM_STATUS" value from "Draft" to "Complete".

It's either my brain cells are exhausted or I'm just not capable on how to do this at the moment.

 

I'm using the code below to update the changes on the form but I can't seem to make the Patch work.

 

Patch(coll_Form,BrowseGallery2.Selected,FORM_STATUS = "Completed");
SubmitForm(EditMainForm);

 

 

So the question is, how do I change the "FORM_STATUS" value from "Draft" to "Complete" when the user clicks on "Save Form as Complete" ?

 

I hope you could help me on this.

 

Thanks! ;3

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @fpc-kdrosario ,

Do you want to change the "FORM_STATUS" value of coll_Form record from "Draft" to "Complete" when you press the "Submit Form Offline" button in your Edit form?

 

Based on the formula that you mentioned, I think there is something wrong with it. Please consider modify your formula as below:

Patch(
      coll_Form,
      BrowseGallery2.Selected,
      {
         FORM_STATUS: "Completed"          // Modify your formula here
      }
);

 

More details about Patch function, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
eka24
Super User
Super User

Try:

Patch(Datasource, First( Filter(Datasource, ID=Textbox1.Text) ), {Status: "Complete" } )

Hello Eka,

 

Is there no other way to reference the selected gallery item aside from using Filter() ? 

 

 

Cheers! ;3

Is that a new question? Is your question resolved

Please be more detailed with the filter question.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

v-xida-msft
Community Support
Community Support

Hi @fpc-kdrosario ,

Do you want to change the "FORM_STATUS" value of coll_Form record from "Draft" to "Complete" when you press the "Submit Form Offline" button in your Edit form?

 

Based on the formula that you mentioned, I think there is something wrong with it. Please consider modify your formula as below:

Patch(
      coll_Form,
      BrowseGallery2.Selected,
      {
         FORM_STATUS: "Completed"          // Modify your formula here
      }
);

 

More details about Patch function, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@v-xida-msft 

 

Ah yes this is what I'm looking for. Thanks!

But what I noticed is that it creates a new entry instead of just modifying the record selected. Is it because of the Patch?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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