pctripathi
(Pratik Chandra Tripathi)
August 20, 2024, 5:14pm
1
I have created a form in which after selecting identity in field 1, I needed to get supervisor details automatically in field 2. Below is my code but its not working.
<Section label="Select Employee:" name="Section 1">
<Field displayName="Enter" filterString="workertype == "Employee"" name="Field 1" required="true" type="sailpoint.object.Identity"/>
</Section>
<Section name="Section 2">
<Field displayName="Manager" dynamic="true" name="Field 2" postBack="true" required="true" type="string">
<Script>
<Source>import sailpoint.object.*;
import sailpoint.tools.Util;
String managerName="";
if(Util.isNotNullOrEmpty(Field 1) ){
Identity idenObj = context.getObjectByName(Identity.class, Field 1);
if (idenObj != null)
{
if(idenObj.getAttribute("hrsupervisorname")!=null)
managerName=idenObj.getAttribute("hrsupervisorname");
}
}
return managerName;</Source>
</Script>
</Field>
</Section>
@pctripathi ,
Are you getting any error? Can you please try to print the Field 1 value by using any log statement first, and see what’s it coming?
Just quick comments:
Filed 1 needs to be postBack = true
value of the field is probably going to be an id of the identity not name
Let’s not have names for fields like “Filed 1” at least have filed_1 or filed1, spaces are never safe.
1 Like
Hi @pctripathi ,
Field1 return the id of the identity. Get the identity object using context.getObjectById method. Check with this code.
<Section label="Select Employee:" name="Section 1">
<Field displayName="Enter" filterString="workertype == "Employee"" name="Field1" postBack="true" required="true" type="sailpoint.object.Identity"/>
</Section>
<Section name="Section 2">
<Field displayName="Manager" dynamic="true" name="Field2" postBack="true" required="true" type="string">
<Script>
<Source>import sailpoint.object.*;
import sailpoint.tools.Util;
String managerName="";
if(Util.isNotNullOrEmpty(Field1) ){
Identity idenObj = context.getObjectById(Identity.class, Field1);
if (idenObj != null)
{
if(idenObj.getAttribute("hrsupervisorname")!=null)
managerName=idenObj.getAttribute("hrsupervisorname");
else
managerName="spadmin";
}
}
return managerName;</Source>
</Script>
</Field>
</Section>
Regards,
Arun
pctripathi
(Pratik Chandra Tripathi)
August 21, 2024, 4:16am
5
Hi @Arun-Kumar
It’s showing a system exception.
iamksatish
(Satish Kurasala)
August 21, 2024, 4:48am
6
@pctripathi
Try this and check
<Section label="Select Employee:" name="Section 1">
<Field displayName="Enter" filterString="workertype == "Employee"" name="Field_1" postBack="true" required="true" type="sailpoint.object.Identity"/>
</Section>
<Section name="Section 2">
<Field displayName="Manager" dynamic="true" name="Field_2" required="true" type="string">
<Script>
<Source>import sailpoint.object.*;
import sailpoint.tools.Util;
String managerName="";
Object field1=form.getField("Field_1").getValue();
if(field1!=null){
String identityId=(String)field1;
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;</Source>
</Script>
</Field>
</Section>
2 Likes
pctripathi
(Pratik Chandra Tripathi)
August 21, 2024, 5:14am
8
Hi @iamksatish
Thanks for the solution. Its working now.
system
(system)
Closed
October 20, 2024, 5:14am
9
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.