Trigger postback or Refresh in Form

Which IIQ version are you inquiring about?

IdentityIQ 8.3

Share all details about your problem, including any error messages you may have received.

I have a dropdown Form filed that is set as postback=true and some other fields set as dynamic=true.

When the user selects a value from the dropdown, the postback works and other fields are updated as expected.

But when in some conditions, we want to programatically update the value in the dropdown field and set it as read-only. So we use below code:

form.getField("xyz").setReadOnly(true);
form.setFieldValue("xyz", "TestValue");

But with this approach, the postback is not triggering, and hence other dynamic=true fields are not updating.

Is there a way to resolve this?

Hi @aseelvn07,

try to use a dynamicValue, like this:

DynamicValue dynamicValue = new DynamicValue();
dynamicValue.setValue(list);
form.getField("xyz").setAllowedValuesDefinition(dynamicValue);
1 Like

Thanks for your response @enistri
Could you please explain how this would resolve my use case?

sure, when you set a field like dynamic and you want managed dynamically the values, you need to use a dynamicValue for refill it.

1 Like

@enistri_devo
actually that didn’t help.

My issue is when end user selects the field value, postback happens as expected.
But when I programmatically set the value for that field, the postback action for that field is not triggering.

1 Like

Hi @aseelvn07,

Could you please share the form you developed for this so I can better understand it?

Regards,
Arun

Hi @Arun-Kumar See below sample code:

    <Field displayName="Choose Certification Template" displayType="combobox" dynamic="true" helpKey="" name="certTemplate" postBack="true" required="true" type="string">
      <AllowedValuesDefinition>
        <Script>
          <Source>  
                                 
            import sailpoint.object.*;
                     
            List availableTemplates = new ArrayList();
			// do business logic and popupulate the availableTemplates
			// availableTemplates.add("abc1");
			// availableTemplates.add("abc2");
            
            if ( availableTemplates.size() == 1 ) { 
            	form.setFieldValue("certTemplate", availableTemplates.get(0) // set the field value programatically instead of end user input in this scenario
            	form.getField("certTemplate").setReadOnly(true);
           
            	return;
            }  
             
            return availableTemplates;
            
          </Source>
        </Script>
      </AllowedValuesDefinition>
      <Attributes>
        <Map>
          <entry key="hidden">
            <value>
              <Script>
                <Source>   
					// part 1
					// execute some code
                                   
                </Source>
              </Script>
            </value>
          </entry>
        </Map>
      </Attributes>
    </Field>
  </Section>
  <Section name="staticTemplateInfo" type="text">
    <Field displayName="" dynamic="true" name="certTemplateDescription" postBack="true">
      <Script>
        <Source>
			// Part 2
			// execute some code
          
        </Source>
      </Script>
    </Field>
  </Section>

Here, for the ‘certTemplate’ field, if the end user manually select a value from dropdown, then the postback gets triggerred and ‘Part 1’ and ‘Part 2’ gets executed.

But based on some condition, if ‘certTemplate’ field is programmatically updated (as shown in the above code), then ‘Part 1’ and ‘Part 2’ doesn’t get executed because postback of ‘certTemplate’ field didn’t get triggered.

Screenshots:
Case 1 - when user manually selects a field, other dynamic=true fields are displayed

Case 2 - when the field is programmatically set and made as read-only, other dynamic=true fields are not displayed/ updated

Hi @aseelvn07,

Please refer the below code. I am able to set the ‘certTemplate’ field programmatically and get the other dynamic=true field are populating.

 <Field displayName="Choose Certification Template" displayType="combobox" dynamic="true" helpKey="" name="certTemplate" postBack="true" required="true" type="string">
            <AllowedValuesDefinition>
              <Script>
                <Source>                                   
            import sailpoint.object.*;                     
            List availableTemplates = new ArrayList();
			// do business logic and popupulate the availableTemplates
			 availableTemplates.add("abc1 Template");
		//	 availableTemplates.add("abc2 Template");
            
           if ( availableTemplates.size() == 1 ) { 
            	form.setFieldValue("certTemplate", availableTemplates.get(0)); // set the field value programatically instead of end user input in this scenario
            	form.getField("certTemplate").setReadOnly(true);
           
            	return;
            }  
             
      //      return availableTemplates;            
          </Source>
              </Script>
            </AllowedValuesDefinition>
            <Attributes>
              <Map>
                <entry key="hidden">
                  <value>
                    <Script>
                      <Source>
              
                return false;
				
								</Source>
                    </Script>
                  </value>
                </entry>
              </Map>
            </Attributes>
          </Field>
          <Field displayName="description" dynamic="true" name="certTemplateDescription" postBack="true">
            <Attributes>
              <Map>
                <entry key="hidden">
                  <value>
                    <Script>
                      <Source>                        
                import sailpoint.object.*;
          import sailpoint.tools.Util;             
          if(Util.isNotNullOrEmpty(certTemplate) ){
                        return false;
                        }
                        return true;
								</Source>
                    </Script>
                  </value>
                </entry>
              </Map>
            </Attributes>
            <Script>
              <Source>           
          return certTemplate+" test description";
        </Source>
            </Script>
          </Field> 

Regards,
Arun

@Arun-Kumar
Thanks for taking time and testing it.
Unfortunately, it won’t work. It worked for you because the ‘certTemplate’ field for you is the first field for you and since the form is getting loaded for the first time you access it, all fields will be refreshed by default and your description field also got refreshed as part of it.

My scenario is different. There’s one field ‘xyz’ which is the only field that shows up when the form is rendered. Based on the value selected in ‘xyz’ field, the ‘certTemplate’ field gets populated.

Hope you understood!

Hi @aseelvn07,

  1. Set the xyz field with postBack="true"
  2. Set certTemplate field with dynamic="true"
  3. In certTemplate field, in AllowedValuesDefinition rule, read the value of xyz field and return the value or values
  4. (opt) in certTemplate, you can add a rule or script for hide/unhide the field readind the value of xyz field

In every case certTemplate field must be locate after the xyz field.

For example:

<Field displayName="field1 " name="field1 " postBack="true" required="true" type="string"/>
<Field displayName="field2 " name="field2 " postBack="true" required="true" type="string"/>
<Field displayName="Email" dynamic="true" name="email" postBack="true" required="true" type="string">
  <RuleRef>
      <Reference class="sailpoint.object.Rule" name="Rule-FieldValue"/>
  </RuleRef>
</Field>

in the rule I do this:

String email = null;
if(field1 != null && field2 != null){
    email = field1 +"@"+field2 ;
}
return email;

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.