Forum Discussion
5 Replies
- neil_lindbergIdeator I
I was on here to try to find how to turn this into a server method, but here is how to add an existing identity as member to an identity. Just a different snippet that works for me. It does: Edit Identity / Add Member / Get Identity to add as member.
<AML> <Item type="Identity" action="edit" where="[identity].name='All Employees'"> <Relationships> <Item type="Member" action="add"> <related_id> <Item type="Identity" action="get"> <name>test user</name> </Item> </related_id> </Item> </Relationships> </Item> </AML>
- Klaus_WroblewskiIdeator IThanks Chris, the code works well!
- christopher_gillisNew MemberHi Klaus, It is not possible to manually set the keyed_name of an item using the AML above; the keyed_name will always be set to the properties marked by the Keyed Name Order column on an ItemType. If no properties are marked, the keyed_name will be set to the ID of the item. Because of this, searching on the keyed_name will not work unless you know the ID of the new item ahead of time. Because the merge action requires some criteria to be passed, I'd recommend using a where clause like below.
Chris<AML> <Item type="Member" action="merge" where="member.source_id = '@1' and member.related_id = '@2'"> <source_id>@1</source_id> <related_id>@2</related_id> </Item> </AML>
Christopher Gillis Aras Labs Software Engineer - Klaus_WroblewskiIdeator IHi Chris, the groups already exist and it could be that the member is already included. Currently when I run the AML the member is always added again. I have tried several variants, like this one, but none worked. <Item type="Member" where="keyed_name='@1'" action="merge"> <keyed_name>@1</keyed_name> <source_id>@1</source_id> <related_id>@2</related_id> </Item> So how to avoid that the member is added more times? I appreciate your comments.
- christopher_gillisNew MemberHi Klaus, The simplest AML to accomplish this would look something like below if you already know the ID of the Group Identity and the member Identity.
Chris<AML> <Item type="Member" action="add"> <source_id>@1</source_id> <related_id>@2</related_id> </Item> </AML>
Christopher Gillis Aras Labs Software Engineer