cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to add "clear" button to form?

How to add "clear" button to form?

This is for adding a clear button to form for users to clear all field values and it's tested in IdentityIQ v7.0.

 

  • Add this highlighted text below to your form:

        <Button action="next" label="Submit"/>        <Button action="cancel" label="Cancel"/>        <Button action="refresh" label="Clear">            <Attributes>                <Map>                  <entry key="Rule" value="rule:Clear-Button"/>                </Map>             </Attributes>       </Button>

  • Import this rule:

 

  1. <?xml version='1.0' encoding='UTF-8'?> 
  2. <!DOCTYPE Rule PUBLIC "sailpoint.dtd""sailpoint.dtd"
  3. <Rule language="beanshell" name="Clear-Button"
  4.  
  5.   <Source><![CDATA[ 
  6. /*******
  7. *                                                                              *
  8. * Generated: Wed Jun 29 18:53:05 PDT 2016                                      *
  9. * Rule: Validation Template                                                    *
  10. * Description: Validation Template                                             *
  11. * Inputs:                                                                      *
  12. *     identity - The Identity object being provisioned.                        *
  13. *     app - The Application object being processed.                            *
  14. *     form - The Form object being processed.                                  *
  15. *     field - The Field object being validated.                                *
  16. *     value - The Object representing the field value.                         *
  17. * Returns:                                                                     *
  18. *     value - An Object (possibly a Collection) of messages resulting from the *
  19. *           validation rule.                                                   *
  20. ******/
  21.  
  22. import org.apache.log4j.Logger; 
  23. import org.apache.log4j.Level; 
  24.  
  25. import sailpoint.object.Field; 
  26. import sailpoint.object.Form; 
  27. import sailpoint.object.Form.Section; 
  28. import sailpoint.object.FormItem; 
  29.  
  30. Logger log = Logger.getLogger("sailpoint.services.rule.buttonrule"); 
  31.  
  32. Form.Section section = form.getSection(); 
  33. for (FormItem item : section.getItems()) { 
  34.      Field field = (Field) item; 
  35.      log.debug("****** field:" + field.getDisplayName()); 
  36.      field.setValue(null); 
  37.  
  38.  
  39.   ]]></Source> 
  40. </Rule> 

 

Line #28: Form.Section section = form.getSection();

Always return the first section of the form. If the fields you want to clear exists in other sections, please use form.getSection(int index);

 

Happy coding

Labels (1)
Version history
Revision #:
2 of 2
Last update:
‎Jul 19, 2023 05:54 PM
Updated by: