I am working on a Sailpoint form that has a field from which the user can select an identity (type=identity). I want to add another field to the form which fetches and displays all the accounts owned by that selected identity in a specific application. How can this be implemented? Thanks.
You can add another field the below of identity (type=identity) field.
<Field columnSpan="1" displayName="Existing Accounts" dynamic="true" multi="true" name="existingaccounts" postBack="true" type="text">
<Attributes>
<Map>
<entry key="readOnly" value="true"/>
</Map>
</Attributes>
<Script>
<Source>
//ADD logic here to get the identity and get the all accounts and return the value
</Source>
</Script>
</Field>
1 Like
You can use the identity service API to get the applications link for the identity.
Identity identity= context.getObjectByName(Identity.class, "identity_name" );
Application sampleApplication = context.getObjectByName(Application.class, "sampleApplication" );
IdentityService idService = new IdentityService(context);
List links = idService.getLinks(identity, sampleApplication );
return links;
1 Like
Hi @waduhek ,
Welcome to the community , you can use below code for same -
<Field dependencies="YourIdentityFieldName" displayName="User Accounts" dynamic="true" multi="true" name="userAcc" postBack="true" type="text">
<Attributes>
<Map>
<entry key="readOnly" value="true"/>
<entry key="hidden">
<value>
<Script>
<Source>
//Put source Code for hidden condition
</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
<Script>
<Source>
import sailpoint.api.IdentityService;
import sailpoint.object.Application;
import sailpoint.object.Identity;
import java.util.List;
public List fetchUserLink(Identity identity)
{
List links=null;
try {
Application sampleApplication = context.getObjectByName(Application.class,"");
IdentityService idService = new IdentityService(context);
links = idService.getLinks(identity, sampleApplication );
}
catch (Exception e)
{
log.error("Exception while fetching Link : "+e);
}
return links;
}
return fetchUserLink(identity);
</Source>
</Script>
</Field>
1 Like