cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mary2
Helper I
Helper I

condition on attachment control in powerapps

i have an icon check mark, which should be enable when an attachment deleted or added ,

i used the formula:

If(DataCardValue27_1.Attachments.Value <> ThisItem.Attachments ,true,false)

but this is not working getting error: invalid argument type

Please help me in resolving this issue.

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Mary2 ,

I made another test and found that: Name field of attachments control could not be used in Concat function, but it could be directly use in First function.

So I'm afraid it's not supported to directly compare data in attachments.

You could compare them one by one, just like this:

If(
   First(DataCardValue29.Attachments).Name in ThisItem.Attachments.DisplayName&&
   Last(FirstN(DataCardValue29.Attachments,2)).Name in ThisItem.Attachments.DisplayName&&
   ....
   false,true
)

 6241.PNG

 

6242.PNG

 

6243.PNG

 

 

Or you could consider use attachments control's Onaddfile, OnRemoveFile,OnUndoRemoveFile properties.

Set variables in these properties. Use these properties to decide the button's visibity.

 

 

Bets 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

7 REPLIES 7
ZabiBabar
Continued Contributor
Continued Contributor

Hi @Mary2 , You are receiving the error becauseDataCardValue27_1.Attachments.Valueand ThisItem.Attachments are not comparable. That is they have different types. Could you please share a screenshot of the form and of the source the form is working on? And also where are you putting the formula that you have shown? By enabling the icon you mean making it visible?

 

I have 4 different forms in a single screen, 3 of them are for attachments only.

I'm using check icon in edit forms to validate/capture the modifications. for all other cards its working fine, but for attachments how to write?

Not getting idea...

attaching screenshots

below is the video im trying to replicate the concept:

https://www.youtube.com/watch?v=Xg-a8rjSzk4

Hi @Mary2 ,

The reason why you can not directly compare DataCardValue27_1.Attachments and ThisItem.Attachments is that these are two tables.

You could only directly compare a value and another value.

So in your issue, you need to use Concat function to transfer table to string, then compare string and string.

Try this formula:

If(Concat(DataCardValue27_1.Attachments,Name&",")<>Concat(ThisItem.Attachments,Name&","),true,false)

 

 

 

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.

Thank you for your support... But i'm getting error...

Hi @Mary2 ,

I made another test and found that: Name field of attachments control could not be used in Concat function, but it could be directly use in First function.

So I'm afraid it's not supported to directly compare data in attachments.

You could compare them one by one, just like this:

If(
   First(DataCardValue29.Attachments).Name in ThisItem.Attachments.DisplayName&&
   Last(FirstN(DataCardValue29.Attachments,2)).Name in ThisItem.Attachments.DisplayName&&
   ....
   false,true
)

 6241.PNG

 

6242.PNG

 

6243.PNG

 

 

Or you could consider use attachments control's Onaddfile, OnRemoveFile,OnUndoRemoveFile properties.

Set variables in these properties. Use these properties to decide the button's visibity.

 

 

Bets 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

Thank you so much for your efforts.

 i have tried using onAddfile and onRemove file of the attachments...

i got the results...

 

Thanks again...

Hi @Mary2 ,

I'm glad that you've solved your problem!

Do you have any other porblem?
If not , could you mark my answer as soltion?

Thanks!

 

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,898)