cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
claudia
Helper IV
Helper IV

Adding or deleting attachments

Dear All,

 

I have the following scenarios:

a)

1. The user add an attachment in a powerapps form

2. The status should change to Pending

 

b)

1. The user delete the attachments

2. The status should change to Draft

 

How can I put the above situations in a formula?

 

I have tried this formula, but if the user add an attachment, the status is still on Draft.

 

Refresh('LABELS - SUPPLIERS RAW MATERIALS');SubmitForm(FormLabel);
If(
CountRows(DataCardValue14.Attachments) <1,
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Draft"}}
)); If(
CountRows(DataCardValue14.Attachments) >0,
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Pending"}}
)
);
Set(
varDialogSaveLabel,
false
);
Navigate('Raw material overview')

 

 

Thank you

Claudia

 

1 ACCEPTED SOLUTION

Accepted Solutions
tchristy99
Helper I
Helper I

To be honest I kinda missed that you were submitting a form in your original post. Try putting this in the button you are using to submit, and take the other formula out of the OnAddFile and OnRemoveFile actions.

 

UpdateContext({attachments: If(IsEmpty(ModifyForm.Attachments), "Empty")});
SubmitForm(FormLabel);
If(attachments = "Empty",
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Draft"}}
),
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Pending"}}
))
;
Set(
varDialogSaveLabel,
false
);

 

You may have to fix the syntax slightly.

Hopefully that does the trick 🤞

View solution in original post

9 REPLIES 9
tchristy99
Helper I
Helper I

Hi,

 

You are very close! For your if statement, try using If(IsEmpty(DataCardValue14.Attachments) then do your patches appropriately. Then I would put that in them in the OnAddFile and OnRemoveFile actions:

tchristy99_0-1619612769846.png

Thank you for your fats reaction!

Please can you explain, what to insert OnAddFile and OnRemoveFile?The If statement?

 

Thank you

Yes, put the if statement in there. Sorry for the lack of description.

It is not working, but maybe I am doing something wrong:

 

Refresh('LABELS - SUPPLIERS RAW MATERIALS');SubmitForm(FormLabel);
If(IsEmpty(ModifyForm.Attachments),
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Draft"}}
));
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Pending"}}
)
;
Set(
varDialogSaveLabel,
false
);
Navigate('Raw material overview')

tchristy99
Helper I
Helper I

Put the submit after the patching

still not working ☹️

 

If(IsEmpty(ModifyForm.Attachments),
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Draft"}}
),
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Pending"}}
))
;SubmitForm(FormLabel);
Set(
varDialogSaveLabel,
false
);
Navigate('Raw material overview')

tchristy99
Helper I
Helper I

To be honest I kinda missed that you were submitting a form in your original post. Try putting this in the button you are using to submit, and take the other formula out of the OnAddFile and OnRemoveFile actions.

 

UpdateContext({attachments: If(IsEmpty(ModifyForm.Attachments), "Empty")});
SubmitForm(FormLabel);
If(attachments = "Empty",
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Draft"}}
),
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Pending"}}
))
;
Set(
varDialogSaveLabel,
false
);

 

You may have to fix the syntax slightly.

Hopefully that does the trick 🤞

View solution in original post

Thank you! I've changed the formula as below and it seems that it works:

 

SubmitForm(FormLabel);
If(
IsEmpty(ModifyForm.Attachments),
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Draft"}}
),
Patch(
'LABELS - SUPPLIERS RAW MATERIALS',
FormLabel.LastSubmit,
{CheckedByIPRA: {Value: "Pending"}}
)
);
Set(
varDialogSaveLabel,
false
);
Navigate(Gallery1)

Excellent!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,375)