Chiru1307
(Chiranjeevi Jamanu)
May 8, 2025, 7:33am
1
I want create a form that gets the roles and role description from the selected application
<Field displayName="Select Role" name="selectedRole" postBack="true" required="true" type="string">
<AllowedValuesDefinition>
<Script>
<Source>
import sailpoint.object.*;
import sailpoint.api.*;
import java.util.*;
List values = new ArrayList();
if(selectedApp != null){
log.error("Print the application : "+ selectedApp);
// Read the choice made in the previous field
Application app = context.getObjectById(Application.class,selectedApp);
log.error("Print the app : "+ app);
if (app != null) {
QueryOptions qo = new QueryOptions();
qo.add(Filter.eq("application", app));
Iterator it = context.search(Bundle.class, qo);
Bundle bu=(Bundle) it.next();
while (it.hasNext()) {
it.next();
values.add(bu.getValue());
}
}
return values;
}
</Source>
</Script>
</AllowedValuesDefinition>
</Field>
ok, and where is the problem?
Chiru1307
(Chiranjeevi Jamanu)
May 8, 2025, 8:55am
3
Hi @enistriminsait , As from your previous posts on role retrival forms I have observed that role application doesn’t saved on Bundle but on BundleProfilerelation. can you please help me on how can I do that
<Field displayName="Roles" dynamic="true" multi="true" name="rolesBasedOnApp" type="Bundle">
<Script>
<Source>
import sailpoint.object.QueryOptions;
import sailpoint.tools.GeneralException;
import sailpoint.tools.Util;
String applicationId = "7f00000190431db2819075ff3b0d2a8e"; // get this dynamically
List roleIds = new ArrayList();
if(Util.isNotNullOrEmpty(applicationId)) {
Map params = new HashMap();
params.put("applicationId", applicationId);
params.put("roleType", "it");
QueryOptions qo = new QueryOptions();
String query = "sql:select sb.id from identityiq.spt_bundle sb INNER JOIN identityiq.spt_bundle_profile_relation sbpr on sb.id = sbpr.bundle_id \n" +
"WHERE sb.`type`=:roleType and sbpr.source_application=:applicationId";
Iterator it = context.search(query, params, qo);
while (it.hasNext()) {
String roleId = (String) it.next();
roleIds.add(roleId);
}
if (it != null) {
Util.flushIterator(it);
}
}
return roleIds;
</Source>
</Script>
</Field>
Chiru1307
(Chiranjeevi Jamanu)
May 9, 2025, 6:38am
5
Hi @kalyan_dev32 ,It is not entering into while. The query not returning any values.
@Chiru1307 Add applicationId and type to the query and run it directly on the database to check for any results. then tweak the code accordingly.