pctripathi
(Pratik Chandra Tripathi)
August 21, 2024, 6:45am
1
I am getting all the available application names in a field. When any application is selected I need to display the roles of that application based on connector type.
Suppose if user selects any application and it is of Active Directory type i.e. AD based connector then showcase roles in next field otherwise do nothing.
How can I get this.
<Section label="Application Name" name="Section 3">
<Field displayName="Select" name="Field_3" required="true" type="Application"/>
<Field displayName="Roles" name="Field 4" postBack="true" type="string"/>
</Section>
Hi @pctripathi ,
Put postBack="true"
in Field_3
Put multi="true"
in Field_4
In Field_4 add a AllowedValuesDefinition(or script) where reading the value of Field_3, the rule return a list of all roles of the application
Also, instead of rule, I think you can change the type Field_4 in Bundle and use filterString on it
pctripathi
(Pratik Chandra Tripathi)
August 21, 2024, 7:35am
3
Hi @enistri_devo
I have followed the steps you mentioned. Step 1 and Step 2 and the last line. I have set the Field_4 type as Bundle. All the roles are now visible there. But what should I write in filterString to filter the field accordingly?
you can build the filter in advaced analytics or (better) you can use a script for filter string where you can insert a complex logic. On this page you can find a good example:
https://community.sailpoint.com/t5/IdentityIQ-Forum/How-to-fix-field-value-in-form-from-disappearing-after-selecting/td-p/90329
pctripathi
(Pratik Chandra Tripathi)
August 21, 2024, 11:15am
5
Hi @enistri_devo
In the link above I checked the codes. There was import statement also with java like
import java.util.List;
import sailpoint.object.Field;
My question is that can we use import java statements in sailpoint or should I use sailpoint forms imports instead. Will it work?
pctripathi
(Pratik Chandra Tripathi)
August 21, 2024, 1:23pm
6
I tried writing and using this script for Field_4 but it is showing system error while saving this.
What must be the error, any suggestions?
&& is showing error in these two line of codes:
if (selectedApp != null && "Active Directory".equalsIgnoreCase(selectedApp.getAttribute("connectorType"))) {
if (roles != null && !roles.isEmpty()) {
Below is the full code I wrote
<Section label="Application Name" name="Section 3">
<Field displayName="Select" name="Field_3" required="true" type="Application" postBack="true"/>
<Field displayName="Roles" name="Field_4" postBack="true" type="string" visible="false">
<Script>
<Source>
import sailpoint.object.*;
import sailpoint.tools.Util;
import java.util.List;
import java.util.ArrayList;
String field4Value = "";
Object field3 = form.getField("Field_3").getValue();
if (field3 != null) {
Application selectedApp = context.getObjectById(Application.class, field3.toString());
if (selectedApp != null && "Active Directory".equalsIgnoreCase(selectedApp.getAttribute("connectorType"))) {
List roles = selectedApp.getEntitlements();
if (roles != null && !roles.isEmpty()) {
field4Value = roles.toString();
form.getField("Field_4").setVisible(true);
} else {
form.getField("Field_4").setVisible(false);
}
} else {
form.getField("Field_4").setVisible(false);
}
}
return field4Value;
</Source>
</Script>
</Field>
</Section>
1 Like
Hi @pctripathi ,
Replace the && with && in your code and save it.
iamksatish
(Satish Kurasala)
August 21, 2024, 1:41pm
8
@pctripathi
Try this
<Section label="Application Name" name="Section 3">
<Field displayName="Select" name="Field_3" postBack="true" required="true" type="Application"/>
<Field displayName="Roles" dynamic="true" multi="true" name="Field_4" type="string">
<Script>
<Source>
import sailpoint.object.*;
import sailpoint.tools.Util;
import java.util.List;
import java.util.ArrayList;
import java.util.Locale;
Locale locale = new Locale("en", "US");
Set field4Value = new HashSet();
Object field3 = form.getField("Field_3").getValue();
if (field3 != null) {
Application selectedApp = context.getObjectById(Application.class, field3.toString());
if (selectedApp != null && "sailpoint.connector.ADLDAPConnector".equalsIgnoreCase(selectedApp.getConnector())) {
Map roles = selectedApp.getEntitlements(locale);
if (roles != null && !roles.isEmpty()) {
field4Value = roles.keySet();
form.getField("Field_4").setHidden(false);
} else {
form.getField("Field_4").setHidden(true);
}
} else {
form.getField("Field_4").setHidden(true);
}
}
return field4Value;
</Source>
</Script>
</Field>
</Section>
I have corrected the syntax and methods in code provided by you
One more thing the code you are trying will not give the entitlement names or entitlements under the app, it will give the type of entitlements
system
(system)
Closed
October 20, 2024, 1:42pm
9
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.