In the Image above
When “Self” radio button is selected a field appears and shows Accounts that are under the requester and have a type as NPIdentity.
When “Other” radio button is selected it shows all the Accounts with type as NPIdentity present in sailpoint environment.
Under Application name in first field i.e. “Select” the requester can pick any application which is a part of Sailpoint.
Below that field i.e. “Select Account field” I am getting the list of Accounts present under selected application name and has type as NPIdentity.
(1) I need to include one more condition with the above condition that while being type as NPIdentity and part of selected application it should also be under the requester. Self or other whatever is selected by the requester.
In below field if “Add” radio button is selected or “Remove” radio button is selected it is showing all the “SAP” type roles in sailpoint.
(2) I need that field to show all the roles/entitlements present in the selected application if “Add” radio button is selected and if “Remove” radio button is selected it should show the roles associated with the selected account.
Please help me in adding these two filters in Account and Role Fields.
<Section label="Requesting For" name="Section 1">
<Field displayName="Select" name="Field_1" postBack="true" required="true" type="string">
<AllowedValuesDefinition>
<Value>
<List>
<String>Self</String>
<String>Others</String>
</List>
</Value>
</AllowedValuesDefinition>
</Field>
<Field displayName="Select NPIdentity SSO ID" dynamic="true" name="Field_2" postBack="true" required="true" type="sailpoint.object.Identity">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>
import sailpoint.object.Field;
Field f1 = form.getField("Field_1");
String f1value = f1.getValue();
boolean hideField = false;
if(!("Self".equalsIgnoreCase (f1value))) {
hideField= true;
field.setRequired(false);
}
else {
field.setRequired(true);
}
return hideField;
</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
<Script>
<Source>import sailpoint.object.Filter;
import sailpoint.object.Identity;
var field = form.getField("Field_2");
if (field == null)
return;
Identity launcherObj = context.getObjectByName(Identity.class, context.getUserName());
var f1 = Filter.eq("manager.name", launcherObj.getName());
f1 = Filter.and(f1, Filter.eq("workertype", "NPIdentity"));
log.error("launcherObj"+launcherObj.getName()+".... " +f1.toString());
field.setFilterString(f1.toString());</Source>
</Script>
</Field>
<Field displayName="Enter NPIdentity SSO ID" dynamic="true" name="Field_3" postBack="true" required="true" type="string">
<AllowedValuesDefinition>
<Script>
<Source>
import sailpoint.object.*;
List identityList = new ArrayList();
QueryOptions qp = new QueryOptions();
qp.addFilter(Filter.eq("lastname","NPIdentity"));
Iterator it = context.search(Identity.class,qp);
while ( it.hasNext() ) {
Identity identity = (Identity)it.next();
//if(null != identity){
if(null != identity && identity.getManager() != null) { //added condition to select identities having managers
identityList.add(identity.getAttribute("workerid"));
}
}
return identityList;
</Source>
</Script>
</AllowedValuesDefinition>
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>import sailpoint.object.Field;
Field f1 = form.getField("Field_1");
String f1value = f1.getValue();
boolean hideField = false;
if(!("Others".equalsIgnoreCase (f1value))) {
hideField= true;
field.setRequired(false);
}
else {
field.setRequired(true);
}
return hideField;</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
<Field displayName="Manager" dynamic="true" name="Field_5" postBack="true" required="true" type="string">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>import sailpoint.object.Field;
Field f1 = form.getField("Field_1");
String f1value = f1.getValue();
boolean hideField = false;
if(!("Others".equalsIgnoreCase (f1value))) {
hideField= true;
field.setRequired(false);
}
else {
field.setRequired(true);
}
return hideField;</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
<Script>
<Source>import sailpoint.object.*;
import sailpoint.tools.Util;
String managerName="";
Object field3=form.getField("Field_3").getValue();
if(field3!=null){
String identityId=(String)field3;
if(Util.isNotNullOrEmpty(identityId)){
Identity idenObj = context.getObjectByName(Identity.class, identityId);
if (idenObj != null)
{
if(idenObj.getAttribute("hrsupervisorname")!=null)
managerName=idenObj.getAttribute("hrsupervisorname");
}
}
}
return managerName;</Source>
</Script>
</Field>
</Section>
<Section label="Application Name" name="Section 2">
<Field displayName="Select" dynamic="true" name="Field_6" postBack="true" required="true" type="Application"/>
<Field displayName="Select Account" dynamic="true" multi="true" name="Field_7" postBack="true" required="true" type="string">
<AllowedValuesDefinition>
<Script>
<Source>
import sailpoint.object.*;
import java.util.List;
import java.util.ArrayList;
import sailpoint.object.Application;
import sailpoint.object.Identity;
import sailpoint.object.Link;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import java.util.Iterator;
import java.util.Collections;
import sailpoint.api.IdentityService;
List accountNames = new ArrayList();
List identityList = new ArrayList();
IdentityService is = new IdentityService(context);
String applicationName = form.getField("Field_6").getValue();
Application App = context.getObjectById(Application.class, applicationName);
QueryOptions qp = new QueryOptions();
qp.addFilter(Filter.eq("lastname","NPIdentity"));
Iterator it = context.search(Identity.class,qp);
while ( it.hasNext() ) {
Identity identity = (Identity)it.next();
if(null != identity @and identity.getManager() != null) {
identityList.add(identity);
}
}
for(Identity id:identityList){
List links= is.getLinks(id,App);
if(null !=links @and links.size()>0){
for(Link link:links){
if(!link.isDisabled())
accountNames.add(link.getDisplayName());
}
}
}
return accountNames;
</Source>
</Script>
</AllowedValuesDefinition>
</Field>
<Field displayName="Add or Remove Role" name="Field_8" postBack="true" required="true" type="string">
<AllowedValuesDefinition>
<Value>
<List>
<String>Add</String>
<String>Remove</String>
</List>
</Value>
</AllowedValuesDefinition>
</Field>
<Field displayName="Roles" dynamic="true" multi="true" name="Field_9" postBack="true" required="true" type="Bundle">
<AllowedValuesDefinition>
<Script>
<Source>
import sailpoint.tools.Util;
import sailpoint.object.Bundle;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
List roleList= new ArrayList();
QueryOptions ops=new QueryOptions();
ops.addFilter(Filter.eq("type","SAP"));
Iterator it = context.search(Bundle.class, ops);
while ( (null != it) && (it.hasNext()) ) {
Bundle record = (Bundle)it.next();
roleList.add(record.getName()) ;
}
return roleList;
</Source>
</Script>
</AllowedValuesDefinition>
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source> import sailpoint.object.Field;
Field f8 = form.getField("Field_8");
String f8value = f8.getValue();
boolean hideField = false;
if(!("Add".equalsIgnoreCase (f8value))) {
hideField= true;
field.setRequired(false);
}
else {
field.setRequired(true);
}
return hideField;</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
<Field displayName="Roles" dynamic="true" multi="true" name="Field_10" postBack="true" required="true" type="Bundle">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source> import sailpoint.object.Field;
Field f8 = form.getField("Field_8");
String f8value = f8.getValue();
boolean hideField = false;
if(!("Remove".equalsIgnoreCase (f8value))) {
hideField= true;
field.setRequired(false);
}
else {
field.setRequired(true);
}
return hideField;</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
</Section>