pctripathi
(Pratik Chandra Tripathi)
February 17, 2025, 1:20pm
1
I have created Three fields.
1st field = Options to be selected
2nd and 3rd Field will be visible based on the options selected above.
<Section name="Section 1">
<Field displayName="Requesting For" displayType="radio" name="Selection" postBack="true" required="true" type="string">
<AllowedValuesDefinition>
<Value>
<List>
<String>Option One</String>
<String>Option Two</String>
</List>
</Value>
</AllowedValuesDefinition>
</Field>
<Field displayName="Select ID" dynamic="true" name="First" postBack="true" type="sailpoint.object.Identity">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>
import sailpoint.object.Field;
boolean hideField = !"Option One".equalsIgnoreCase(form.getField("Selection").getValue());
field.setRequired(!hideField);
return hideField;
</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
<Field displayName="Enter ID" dynamic="true" name="Second" postBack="true" type="string">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>
import sailpoint.object.Field;
boolean hideField = !"Option Two".equalsIgnoreCase(form.getField("Selection").getValue());
field.setRequired(!hideField);
return hideField;
</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
</Section>
In case the option is long or there are alot of options, adding options in everyfield is a bit lengthy.
So I descided to use index. Here I will define all the options in a list and the fields will contain 0,1,2 … to hide or unhide them but did not work.
Also I tried giving value to every option like 0 or 1 and tried, it also seems not supported or something.
Any different approach I can try?
Arpitha1
(Arpitha Halaguru Kunne Gowda)
February 18, 2025, 4:14am
2
@pctripathi Can you explain the issue? I just tried importing this form section into my local and it is working fine.
pctripathi
(Pratik Chandra Tripathi)
February 18, 2025, 7:01am
3
@Arpitha1
Like in this code below
boolean hideField = !"Option One".equalsIgnoreCase(form.getField("Selection").getValue());
I am defining “Option One” so this field will be visbible if “Option One” is selected.
I want to use different scenario here, insted of defining the option in the script I want to use something more like a global variable, in case the option and number of options are too long to mention everytime in every field.
Arpitha1
(Arpitha Halaguru Kunne Gowda)
February 18, 2025, 7:26am
4
You can use below one. First you try with the script, if it works then keep it in a rule and can refer it in other fields too.
boolean hideField = !field.getName().equalsIgnoreCase(form.getField("Selection").getValue());
pctripathi
(Pratik Chandra Tripathi)
February 18, 2025, 10:34am
5
Can you add your piece of code in mine which I have sent above so its clear how to get it working?
Arpitha1
(Arpitha Halaguru Kunne Gowda)
February 18, 2025, 10:42am
6
Attaching the code here
<Section name="Section 1">
<Field displayName="Requesting For" displayType="radio" name="Selection" postBack="true" required="true" type="string">
<AllowedValuesDefinition>
<Value>
<List>
<String>Option One</String>
<String>Option Two</String>
</List>
</Value>
</AllowedValuesDefinition>
<OwnerDefinition value="IIQRequester"/>
</Field>
<Field displayName="Option One" dynamic="true" name="Option One" postBack="true" type="sailpoint.object.Identity">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>
import sailpoint.object.Field;
boolean hideField = !field.getName().equalsIgnoreCase(form.getField("Selection").getValue());
field.setRequired(!hideField);
return hideField;
</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
<Field displayName="Enter ID" dynamic="true" name="Option Two" postBack="true" type="string">
<AllowedValuesDefinition>
<Script>
<Source>
import sailpoint.object.Field;
boolean hideField = !field.getName().equalsIgnoreCase(form.getField("Selection").getValue());
field.setRequired(!hideField);
return hideField;
</Source>
</Script>
</AllowedValuesDefinition>
</Field>
</Section>
pctripathi
(Pratik Chandra Tripathi)
February 18, 2025, 1:05pm
7
Did not work after using this approach.
Arpitha1
(Arpitha Halaguru Kunne Gowda)
February 19, 2025, 2:05am
8
Are you getting any error? It worked fine to me
pctripathi
(Pratik Chandra Tripathi)
April 1, 2025, 7:06am
9
I used a custom file for the reference.