Share all details related to your problem, including any error messages you may have received.
There is a quicklink that triggers a workflow. Within a workflow a form needs to be generated that may contain n number of fields (Depending on situation). How can we achieve that ? Below is the code snipped I am using in a workflow rule to generate a form. The form doesn’t load. There is no error in logs.
import sailpoint.object.*;
import sailpoint.api.*;
import java.util.*;
import sailpoint.object.Workflow.Step;
import sailpoint.object.Form.Section;
import sailpoint.object.Form.Button;
Workflow.Approval wa= new Workflow.Approval();
Workflow.Step ws= new Workflow.Step();
Button btn= new Button();
Form forms = new Form();
forms.setName("Hello Form");
forms.setLabelAlign("Form Label");
System.out.println("-------------------------");
Section sects = new Section();
sects.setName("Section name");
sects.setType("text");
sects.setLabel("Sec Label");
Field fv = new Field();
fv.setName("fieldname");
fv.setType("String");
fv.setValue(workflow.get("launcher"));
sects.add(fv);
forms.add(sects);
forms.setPageTitle("Form Page Title");
forms.add(fv);
btn.setAction("next");
btn.setLabel("Ok");
List bList = new ArrayList();
bList.add(btn);
forms.setButtons(bList);
// context.saveObject(forms);
// context.commitTransaction();
Identity idn = context.getObjectByName(Identity.class,"spadmin");
System.out.println("idn : "+idn);
System.out.println("forms : "+forms.toXml());
wa.setName("workflow approval");
wa.setForm(forms);
wa.setOwner(workflow.get("launcher").toString());
wa.setReturn("");
wa.setSend("");
wa.setAssimilated(true);
//
System.out.println("wa : "+wa.toXml());
System.out.println("ws : "+ws.toXml());
return wa;
Hi Tanay,
First of all I would suggest to not create form from scratch as it might be tricky. Apart from that what you can do is to just create a standard step with the Form and in this form just create a single field which is hidden.
In this field you can write beanshell that will customize the form object. That gives you benefit that form itself is created by Sailpoint and the only thing you do is to dynamically build it inside.
Agreed with @kjakubiak, add on to a form template. Here is another example that uses a workflow step to add to a form as opposed to doing it directly inside the form itself. I used this before to add fields for each identity attribute.
<Step icon="Task" name="Build Form" posX="225" posY="25" resultVariable="inputForm">
<Script>
<Source><![CDATA[
import sailpoint.object.Form;
import sailpoint.object.Form.Section;
import sailpoint.object.Field;
import sailpoint.object.ObjectConfig;
import sailpoint.object.ObjectAttribute;
//Get Form and make a copy
Form form = context.getObjectByName(Form.class, actionCodeFormName);
Form formCopy = form.derive(context);
context.decache(form);
//Add identity attributes to section
ObjectConfig objConfig = context.getObjectByName(ObjectConfig.class, "Identity");
List extendedList = objConfig.getObjectAttributes();
Section attributeSection = formCopy.getSection("Section-IdentityAttributes");
for (ObjectAttribute objAtr : extendedList) {
Field currentValueField = new Field();
currentValueField.setReadOnly(true);
currentValueField.setName(objAtr.getName());
currentValueField.setDisplayName(objAtr.getName() + " - Current Value");
currentValueField.setColumnSpan(1);
Field newValueField = new Field();
newValueField.setName("new_" + objAtr.getName());
newValueField.setDisplayName(objAtr.getName() + " - New Value");
newValueField.setColumnSpan(1);
attributeSection.add(currentValueField);
attributeSection.add(newValueField);
}
return formCopy;
]]></Source>
</Script>
<Transition to="Input Form"/>
</Step>