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.

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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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