Group Identity Member AML

How can I add members to a group identity with AML code using Batch Loader? I appreciate your comments.
  • Hi 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.
    <AML>
    <Item type="Member" action="add">
    <source_id>@1</source_id>
    <related_id>@2</related_id>
    </Item>
    </AML>
    Chris
    Christopher Gillis Aras Labs Software Engineer
  • Hi 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.
  • Hi 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.
    <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>
    Chris
    Christopher Gillis Aras Labs Software Engineer
  • Thanks Chris, the code works well!
  • 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>