cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

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

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
Highlighted
Community Champion
Community Champion

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

Try:

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

Highlighted
Helper I
Helper I

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

Hello Eka,

 

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

 

 

Cheers! ;3

Highlighted
Community Champion
Community Champion

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

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.

Highlighted
Community Support
Community Support

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

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

Highlighted
Helper I
Helper I

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

@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
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,646)