I am creating a form in which i need to hide and unhide below field according to the option selected in the dropdown field. I wrote a code which is showing system error when i am trying to open the form using quicklink. The code is below.
<Field displayName="select" dynamic="true" name="Field 6" postBack="true" required="true" type="string">
<AllowedValues Definition>
<Value>
<<List>
<String>Modify Existing Service Account Name</String>
<String>Modify Existing Service Account Description</String>
</List>
</Value>
</AllowedValues Definition>
</Field>
<Field displayName="Enter existing Service Account Name" helpKey="Enter existing group name from the domain which requires to be Modified/Deleted/Transfer Owner Ship." name="Field 7" required="true" type="string"/>
<Field displayName="Enter new Service account Name" dynamic="true" helpKey="Enter new name of the group that should be created or modified in the domain." name="Field 8" required="true" type="string">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>
boolean hideField = false;
if(!("Modify Existing Service Account Description".equalsIgnoreCase (Field 6))) {
hideField= true;
field.setRequired(false);
}
else {
hideField = false;
field.setRequired(true);
}
return hideField:
</Source>
</Script>
</value> </entry>
</Map>
</Attributes>
</Field>
I did somethings similar for Edit Identity form but I think you can apply for other type of forms.
I created a checkbox and rule.
The rule is assigned to the section that I want hide/unhide to hidden attribute. The rule check the state of checkbox and return true or false:
<Field displayName="select" dynamic="true" name="Field 6" postBack="true" required="true" type="string">
<AllowedValues Definition>
<Value>
<<List>
<String>Modify Existing Service Account Name</String>
<String>Modify Existing Service Account Description</String>
</List>
</Value>
</AllowedValues Definition>
</Field>
<Field displayName="Enter existing Service Account Name" helpKey="Enter existing group name from the domain which requires to be Modified/Deleted/Transfer Owner Ship." name="Field 7" required="true" type="string"/>
<Field displayName="Enter new Service account Name" dynamic="true" helpKey="Enter new name of the group that should be created or modified in the domain." name="Field 8" required="true" type="string">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>
import sailpoint.object.Field;
Field f6 = form.getField("Field 6");
String f6value = f6.getValue();
boolean hideField = false;
if(!("Modify Existing Service Account Description".equalsIgnoreCase (f6value))) {
hideField= true;
field.setRequired(false);
}
else {
field.setRequired(true);
}
return hideField;
</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>
a. Create a Hidden Section for process the field.
- Here you can create Field, that will read the value from any field and you can hide / unhide multiple fields and change the read only also.
@pctripathi I agree with @pravin_ranjan approach. Hidden field is always helpful if we want to do some background processing and then use that field value wherever its required. Thankyou Sir.