pctripathi
(Pratik Chandra Tripathi)
September 4, 2024, 12:41pm
1
Hi,
I was creating a form in which I wanted to filter Identities in order to show in dropdown field.
Below is the code for the particular field.
<Field displayName="Enter NPIdentity SSO ID" dynamic="true" filterString="workertype == "NPIdentity"" name="Field_3" 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(!("Others".equalsIgnoreCase (f1value))) {
hideField= true;
field.setRequired(false);
}
else {
field.setRequired(true);
}
return hideField;</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
Now I have to change this
Here in this code I am getting Identities in the column by name. I want to view the worker ID instead of name in the field.
Attribute for which is workerid.
Also want to add a filter criteria that the last name of the identities which will be visible in the ropdown will only be “NPIdentity”. And attribute for last name is lastname.
What should I change or implement in my code in order to achieve this?
Arun-Kumar
(Arun Kumar)
September 4, 2024, 2:57pm
2
Hi @pctripathi ,
In the drop down, you will get only workerid whose lastname is “NPIdentity”. try with this.
<Field displayName="Enter NPIdentity SSO ID" dynamic="true" name="Field_3" 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>
<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){
identityList.add(identity.getAttribute("workerid"));
}
}
return identityList;
</Source>
</Script>
</AllowedValuesDefinition>
</Field>
pctripathi
(Pratik Chandra Tripathi)
September 5, 2024, 2:44pm
4
Hi @Arun-Kumar
After using the code above the code I added to fetch manager details below stopped working.
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.getObjectById(Identity.class, identityId);
if (idenObj != null)
{
if(idenObj.getAttribute("hrsupervisorname")!=null)
managerName=idenObj.getAttribute("hrsupervisorname");
}
}
}
return managerName;
Arun-Kumar
(Arun Kumar)
September 5, 2024, 2:53pm
5
Form Field_3 return the workerid from the identity. It will not return the identity Id. You need to update the logic for manager field.
try this one to get the identity
Identity idenObj = context.getObjectByName(Identity.class,idntityId);
1 Like
system
(system)
Closed
November 4, 2024, 4:02pm
8
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.