I'm having a specific requirement where on a button click, need to duplicate that entity's Related record along with its related records.
Basically entity A -> entity B -> entity C.
What I have achieved so far,
On click of Record(X) of Entity A, collect data in collection of all related records (Y) in Entity B and another collection of records relating to Record(Y) in entity C.
Now I have duplicated Record(X) in Entity A and related Record(Y) to Entity B.
I'm stuck where I need to duplicate Record(Z) from entity C related to new Record(Y) from Entity B.
I'm gone through MS Docs. came across With() function which can help but I have no idea how to use. With Function
I need to perform ForAll() into With.
Need Advice.
Thanks
Hi @Ethan_R,
You would need to do something like this. Notice the difference in the names EntityA, EntityB and EntityC. EntityAID/EntityBID is the ID of the respective patch results.
With(
Patch(EntityAs, Defaults(EntityAs), {Column1: "XYZ", Column2: "ABC"}),
ForAll(EntityBsGallery,
With(
Patch(EntityBs, Defaults(EntityBs), {EntityA: EntityAID, Column1: EntityBGalleryColumn}),
ForAll(EntityCsGallery,
Patch(EntityCs, Defaults(EntityCs), {EntityB: EntityBID, Column1: EntityCGalleryColumn})
)
)
)
)
Hope this helps!
Hi @EricRegnier ,
I have a problem that column names are same.
How will I know which ID is returned from With function ?
Since its showing alot of errors
You don't need to know the ID, that will be known at runtime. The ID is returned from the respective previous Patch.
Since its not allowing...
I've created a collection where I only need to patch Entity B records and related C records to new A.
Here's some info...
Collection consist EntityB and relating EntityC records
ForALl(
collection,
With(
Patch(
EntityB
),
Patch(
EntityC
)
)
)
But it shows errors for 2nd patch.
Can't understand what's the issue
Can you share the full error message and the full expression? Thanks!
User | Count |
---|---|
20 | |
11 | |
8 | |
5 | |
5 |
User | Count |
---|---|
34 | |
32 | |
19 | |
18 | |
7 |