cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
afara
Advocate II
Advocate II

Create new record on sharepoint list everytime a change is made to an item in the Edit form on Powerapp

Hello,

I am pretty new to powerapps and i am stuck on a requirement that seems pretty straightforward. 

I have a sharepoint list that is populated by collected survey details. On my reviewer powerapp end, i get to fetch each survey detail for further analysis and classification.

 

All this analysis and classification is done on the edit form section. My problem is, i don't want to replace the original survey details on my sharepoint list A with these edits and classification, but would like these changes to be created as a new item (something like a child item with reference to original survey item) on a new sharepoint list so as not to lose the original submitted survey details. This is because the end users powerapp should only be able to see the edited and classified survey details. I tried creating a new sharepoint list with exact fields like the original sharepoint list, with an extra ID field (ParentID) that is similar to the original survey record ID. This list is to be populated every time the SubmitForm button is clicked on the edit form using Patch function. This worked well, but unfortunately i got stuck on records that have attachments. I can't seem to be able to populate my attachment field on my second list using the patch function in case a reviewer decides to add another attachment to a survey. Kindly advice on what to do. And if there is any other easier way of doing this than what i am currently trying to do.  I can't seem to wrap my head around the parent-child relationship situation which i suspect is the right way to implement this. 

Currently this is what i have on my onSelect property on my Submit button on the EditForm. 'ACRPE Topic Message Details' is the name of my second sharepoint list.

 

SubmitForm(EditForm1);
Refresh('ACRPE Topic Message Details');
Patch(
    'ACRPE Topic Message Details',
    Defaults('ACRPE Topic Message Details'),
    {
        ParentID: BrowseGallery2.Selected.ID,
        'Message Reviewed By': BrowseGallery2.Selected.'First Reviewer',
        Topic: BrowseGallery2.Selected.Topic,
        'Message Classification': BrowseGallery2.Selected.'Message Classification'.Value,
        'Enriched Message': BrowseGallery2.Selected.'Enriched Message',       
        Attachments: BrowseGallery2.Selected.Attachments
    }
);

 

  

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @afara ,

Do you mean that you have trouble in updating attachments by using patch function?
The reason why you met this problem is that it's not supported to use patch function in attachments.

Attachments only supported in form and being updated by submitform function.

 

I suggest you: insert another form only for attachments field, not choose other fields in this form.

Firstly using patch to create a new record with other fields, then use the new form to update this created item's attachments.

 

Try this formula:

SubmitForm(EditForm1);
Refresh('ACRPE Topic Message Details');
Patch(
    'ACRPE Topic Message Details',
    Defaults('ACRPE Topic Message Details'),
    {
        ParentID: BrowseGallery2.Selected.ID,
        'Message Reviewed By': BrowseGallery2.Selected.'First Reviewer',
        Topic: BrowseGallery2.Selected.Topic,
        'Message Classification': BrowseGallery2.Selected.'Message Classification'.Value,
        'Enriched Message': BrowseGallery2.Selected.'Enriched Message',       
    }
);
SubmitForm(newforname)
//please replace with your new form's name

set the new form's Item:

Last('ACRPE Topic Message Details')
//the item that was created just now

 

Best regards,

Community Support Team _ Phoebe Liu
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

1 REPLY 1
v-yutliu-msft
Community Support
Community Support

Hi @afara ,

Do you mean that you have trouble in updating attachments by using patch function?
The reason why you met this problem is that it's not supported to use patch function in attachments.

Attachments only supported in form and being updated by submitform function.

 

I suggest you: insert another form only for attachments field, not choose other fields in this form.

Firstly using patch to create a new record with other fields, then use the new form to update this created item's attachments.

 

Try this formula:

SubmitForm(EditForm1);
Refresh('ACRPE Topic Message Details');
Patch(
    'ACRPE Topic Message Details',
    Defaults('ACRPE Topic Message Details'),
    {
        ParentID: BrowseGallery2.Selected.ID,
        'Message Reviewed By': BrowseGallery2.Selected.'First Reviewer',
        Topic: BrowseGallery2.Selected.Topic,
        'Message Classification': BrowseGallery2.Selected.'Message Classification'.Value,
        'Enriched Message': BrowseGallery2.Selected.'Enriched Message',       
    }
);
SubmitForm(newforname)
//please replace with your new form's name

set the new form's Item:

Last('ACRPE Topic Message Details')
//the item that was created just now

 

Best regards,

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

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,851)