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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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