web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding or deleting att...
Power Apps
Answered

Adding or deleting attachments

(0) ShareShare
ReportReport
Posted on by 208

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

 

Categories:
  • TC-26111857-0 Profile Picture
    70 on at

    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

  • claudia Profile Picture
    208 on at

    Thank you for your fats reaction!

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

     

    Thank you

  • TC-26111857-0 Profile Picture
    70 on at

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

  • claudia Profile Picture
    208 on at

    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')

  • TC-26111857-0 Profile Picture
    70 on at

    Put the submit after the patching

  • claudia Profile Picture
    208 on at

    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')

  • Verified answer
    TC-26111857-0 Profile Picture
    70 on at

    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 🤞

  • claudia Profile Picture
    208 on at

    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)

  • TC-26111857-0 Profile Picture
    70 on at

    Excellent!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard