cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lexicron
Resolver II
Resolver II

How to use ForAll and Remove to delete a bunch of CDS records at once?

I have a collection "ToRemove" that has a bunch of items added to it from the CDS entity "CDSEntity1". I have a button to delete the items found in ToRemove from the same CDSEntity1. The table structure of ToRemove is identical to CDSEntity1 due to the way items were collected into ToRemove. Both have the same unique ID fields "Unique ID".

 

My formula doesn't work:

 

ForAll(ToRemove,
    Remove(CDSEntity1, LookUp(CDSEntity1, 'Unique ID'='Unique ID'))
);

 

 

There is no formula error but I'm getting a runtime error:

 

The requested operation is invalid. Server Response: CDSEntity1 failed: the right side of the 'Equal' operator must be a constant value.

 

 

How should I rewrite my formula please?

1 ACCEPTED SOLUTION

Accepted Solutions
Lexicron
Resolver II
Resolver II

Doh, you don't need a ForAll loop to do this.

 

Remove(CDSEntity1, ToRemove);

 

works!

View solution in original post

3 REPLIES 3
Lexicron
Resolver II
Resolver II

Doh, you don't need a ForAll loop to do this.

 

Remove(CDSEntity1, ToRemove);

 

works!

View solution in original post

KrishnaV
Super User III
Super User III

Hi @Lexicron ,

 

On button onSelect event use this below formula

Remove(CDSEntity1, recordtoberemoved);

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

 

Regards,

Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

incase if it is from a gallery selection:

OnSelect: RemoveIf(cdsEntity1;MyGallery.Selected.Button2.Pressed)

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

Regards,

Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (30,890)