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 🤞

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
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

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