Is there a way to get the id of the duplicated record in the workflow?
Announcement
Collapse
No announcement yet.
How to get original record id of cloned object?
Collapse
X
-
Hi romach,
Can you please tell what you mean by the cloning? How is this cloning done? Maybe you mean duplicating?
Please provide a little more detail and screenshots so that we can help you more quickly and efficiently.
-
How to get duplicate contact ID instead of original contact ID in our created contact by Duplicate function:- Create a field with type Boolean for the required Entity (in my example it is Contact).
- Create a Varchar field for the same Entity with option Read-only.
- In Administration -> Entity Manager -> Contact -> Formula insert the formula:
Code:ifThen( entity\isNew() == true && thisIsADuplicateBoolean == true, thisIsADuplicateVarchar = id );
Now, at the time of duplicating a Contact, check the thisIsADuplicateBoolean field and after creating a duplicate contact, get the Id in the thisIsADuplicateVarchar field.
Also, if desired, you can make thisIsADuplicateBoolean Read-only after creating a duplicate.Last edited by victor; 04-21-2023, 02:28 PM.
- Likes 1
Comment
-
Quite a genius move! I read the formula and I can see it but I don't get the logic in the code.
- In my previous post the solution how to get duplicate contact ID instead of original contact ID in our created contact by Duplicate function.
Comment
-
romach, esforim,
ID of the original contact in one of the fields of the duplicate contact that was created by Duplicate function:- In Administration -> Entity Manager -> Contact -> Fields we create an originalId field with Varchar type.
- In Administration -> Entity Manager -> Contact -> Formula we create a fomula:
Code:ifThen( entity\isNew() && originalId == null, originalId = id ); ifThen( entity\isNew() != true && originalId == null, originalId = id ); ifThen( entity\isNew() != true && originalId != id, originalId = entity\attributeFetched('originalId') );
- We do the Recalculate Formula for the necessary (or better in general for all) contacts (as shown in the screenshot 1).
- After we make Recalculate Formula for the required contacts (or after creating a new contact) originalId field will be filled in each of them. And at this stage, the originalId field is equal to id. (screenshot 2).
- After we do Duplicate function, the duplicate contact will have the id of the original contact in the originalId field. In this way, we received contact B, which in the originalId field contains the value of the Id field of contact A.
- If we want to duplicate contact B (in the originalId field, which still contains the value of the Id field of contact A) so that in the created contact C, the originalId field contains the Id of contact B, before Duplicate function, we need to clear the originalId field in contact B.
Last edited by victor; 04-21-2023, 03:14 PM.
Comment
Comment