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:
- <?xml version='1.0' encoding='UTF-8'?>
- <!DOCTYPE Rule PUBLIC "sailpoint.dtd""sailpoint.dtd">
- <Rule language="beanshell" name="Clear-Button">
- <Source><![CDATA[
- /*******
- * *
- * Generated: Wed Jun 29 18:53:05 PDT 2016 *
- * Rule: Validation Template *
- * Description: Validation Template *
- * Inputs: *
- * identity - The Identity object being provisioned. *
- * app - The Application object being processed. *
- * form - The Form object being processed. *
- * field - The Field object being validated. *
- * value - The Object representing the field value. *
- * Returns: *
- * value - An Object (possibly a Collection) of messages resulting from the *
- * validation rule. *
- ******/
- import org.apache.log4j.Logger;
- import org.apache.log4j.Level;
- import sailpoint.object.Field;
- import sailpoint.object.Form;
- import sailpoint.object.Form.Section;
- import sailpoint.object.FormItem;
- Logger log = Logger.getLogger("sailpoint.services.rule.buttonrule");
- Form.Section section = form.getSection();
- for (FormItem item : section.getItems()) {
- Field field = (Field) item;
- log.debug("****** field:" + field.getDisplayName());
- field.setValue(null);
- }
- ]]></Source>
- </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
Comments
Aug 07, 2024
08:04 PM
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Content to Moderator
Aug 07, 2024
08:04 PM
Is there a way to add a script to a button instead of a rule?
Version history
Revision #:
2 of 2
Last update:
Jul 19, 2023
05:54 PM
Updated by: