Which IIQ version are you inquiring about?
8.4
Share all details about your problem, including any error messages you may have received.
Hi all, I have 2 questions regarding custom workflow:
- Can I set the status of my workitem depending on API response received in my custom rule which is being called from the workflow? The workitem status should be Finished if API response is 200 and all other API response, workitem status should be Rejected. Shared my current code for reference
- Based on my testing, I noticed the work item state is already set before the rule is executed. So would like to know if I can set the work item state at a later point?
- On the UI is there any way I can just put a static text without a field? Example in screenshot (the text in red is the static text I like to achieve)
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Workflow PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Workflow explicitTransitions="true" name="Self Service View Workflow">
<!-- Define all required variables -->
<Variable input="true" name="launcher"/>
<Variable name="inl"/>
<Variable name="email"/>
<Variable name="mobileNumber"/>
<Variable name="ruleResult"/>
<Variable initializer="false" name="isValid"/>
<Variable initializer="true" name="trace"/>
<Variable initializer="new java.util.ArrayList()" name="validationErrors"/>
<Step icon="Start" name="Start" posX="36" posY="82">
<Transition to="Display Form"/>
</Step>
<Step icon="Default" name="Display Form" posX="128" posY="84">
<Approval name="Account Guest Invite" owner="script:return context.getUserName();" return="email,mobile" send="">
<Form name="Account Guest Invite">
<Attributes>
<Map>
<entry key="pageTitle" value="Create Account"/>
<entry key="errors" value="ref:validationErrors"/>
</Map>
</Attributes>
<Section name="User Details">
<Field displayName="***" name="***" type="string" required="true" postBack="true">
</Field>
<Field displayName="Email" name="email" type="string" required="true" dependencies="***" readOnly="true" dynamic="true">
<Script>
<Source>
import sailpoint.object.*;
//do something
</Source>
</Script>
</Field>
<Field displayName="Mobile Number" name="mobile" type="string" required="true" helpKey="User’s Singapore Mobile Number (eg: +65-8xxxxxxx,+65-9xxxxxxx)">
<ValidationScript>
<Source>
import sailpoint.object.*;
import sailpoint.tools.GeneralException;
import org.apache.commons.lang.StringUtils;
import sailpoint.tools.Message;
import java.util.List;
import java.util.Arrays;
import java.util.regex.Pattern;
Message msg = new Message();
if (mobile != null && !StringUtils.isEmpty(mobile.trim())) {
// Remove all spaces from the phone number
String phoneValue = mobile.trim().replaceAll("\\s+", "");
// Regex pattern for +65-xxxxxxxx
String phonePattern = "^\\+65-\\d{8}$";
if (!Pattern.matches(phonePattern, phoneValue)) {
msg.setKey("Invalid phone number format. Phone number must be in format +65-xxxxxxxx where x are digits");
return msg;
}
}
return null;
</Source>
</ValidationScript>
</Field>
</Section>
<Section name="Section 2" label="Note: Upon submission you will receive an email on the submission outcome"/>
<Button action="next" label="Submit"/>
<Button action="cancel" label="Cancel"/>
</Form>
</Approval>
<Transition to="Execute Rule">
<Script>
<Source>
boolean result =false; if(lastApprovalState.equalsIgnoreCase("Finished")){ result = true; } return result;
</Source>
</Script>
</Transition>
</Step>
<Step action="rule:Account Invite" icon="Default" name="Execute Rule" posX="255" posY="140" resultVariable="response">
<Transition to="Stop"/>
</Step>
<Step icon="Stop" name="Stop" posX="342" posY="76"/>
</Workflow>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule language="beanshell" name="Account Invite" type="Workflow">
<Description>A rule used by a Workflow to determine a step action or variable value. Note that an Attributes map of all variables from the current WorkflowContext, merged with the arguments from the Step, is also passed into the workflow rule.</Description>
<Signature returnType="Object">
<Inputs>
<Argument name="log" type="org.apache.commons.logging.Log">
<Description> The log object associated with the SailPointContext. </Description>
</Argument>
<Argument name="context" type="sailpoint.api.SailPointContext">
<Description> A sailpoint.api.SailPointContext object that can be used to query the database if necessary. </Description>
</Argument>
<Argument name="wfcontext">
<Description> The current WorkflowContext. </Description>
</Argument>
<Argument name="handler">
<Description> The workflow handler associated with the current WorkflowContext. </Description>
</Argument>
<Argument name="workflow">
<Description> The current Workflow definition. </Description>
</Argument>
<Argument name="step">
<Description> The current Step. </Description>
</Argument>
<Argument name="approval">
<Description> The current Approval. </Description>
</Argument>
<Argument name="item">
<Description> The WorkItem being processed. </Description>
</Argument>
</Inputs>
<Returns>
<Argument name="Object">
<Description> The result of the workflow rule; dependent on the rule itself. </Description>
</Argument>
</Returns>
</Signature>
<Source>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;
import java.util.ArrayList;
import java.util.List;
import java.util.Base64;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;
import sailpoint.tools.Util;
import java.util.HashMap;
import java.util.Map;
import sailpoint.object.EmailTemplate;
import sailpoint.object.EmailOptions;
import sailpoint.object.Identity;
Logger log = Logger.getLogger("sailpoint.services.rule.buttonrule");
// Initialize variables to store form values
String finalAccessToken = "";
HttpClient httpClient = null;
String response = "";
String requester = "";
String requesterEmail = "";
// attempted to get workitem here but nothing
if(item != null){
log.error("test");
}
//calling api code here
</Source>
</Rule>
Any help would be appreciated!