Add Approvals to request when all the associated tasks are completed.
Requirement:
Request approvals have to be added only after all the associated tasks of a request are completed.
If the approvals are added via the request workflow, then it would be automatically triggered when a request is created. To avoid this, we need to add the approvals in request additional fields.
These can either be added directly or a FAFR script can be used to load all the users in the organisation with their user ids.
Execution Steps:
- Create new additional fields for the request to hold the approver information and update the API name in the script.
- Goto: Admin > Incident Additional Fields
- Each stage must be configured as a separate additional field.
- Connect to Db and execute the below query. Restart your instance for this to take effect.
- update globalconfig set paramvalue=true where parameter='AllowUserAPIInRequesterLogin'
- Go to Admins > Status > Create a custom request status "Waiting for approvals".
- Go to Admin > Service Templates > Select a particular template > Field and Form Rules > Rule execution - On Create / Edit > Event - "On Form Load" >> Action > Execute Script > Use the FAFR script.
var fafrKeyList = ["WorkOrder_Fields_UDF_CHAR1", "WorkOrder_Fields_UDF_CHAR10", "WorkOrder_Fields_UDF_CHAR13", "WorkOrder_Fields_UDF_CHAR2", "WorkOrder_Fields_UDF_CHAR4"];
var selectMultiple = true;
fafrKeyList.forEach(listUsers);
function listUsers(fafrKey) {
var cs_value = $CS.getValue(fafrKey);
$CS.referField(fafrKey, "users", {
url: "/api/v3/users",
multiple: selectMultiple,
needID: true
});
if (cs_value !== "") {
var arr = cs_value.split(",");
var arr_length = arr.length;
var list = [];
for (var i = 0; i < arr_length; i++) {
list.push({
id: arr[i],
text: arr[i]
});
}
$CS.element(fafrKey).select2("data", list);
} }
- Goto Admin > Developer Space > Global function > New > Paste the content from the attachment GF_4 - Configuration.txt and save it with a name.
- Update the URL and integration key in the script.
- You can get the integration key under Admin > Integrations > Integration Key > New
- Please use an integration key with admin privilege, as there wont be any role related permission issues.
- Update the integration key in the global function.
- Goto Admin > Developer Space > Request Custom Function > New > Paste the "setApprovals.txt" content and save it with a name.
- Goto Admin > Developer Space > Task Custom Functions. Create a new function.
- Refer to the attached script. (addApprovals.txt.)
- Update the global function count and custom request status name in the script as per your instance.
- Configure Task custom trigger to get executed on every task being closed with "Module" as "Request".
- Configure Request custom trigger to get executed every time the request is moved to the custom status.
New to ADSelfService Plus?
Related Articles
How to close associated incident requests of change request automatically
This post describes the use of a python script to close change that are in a specific stage using Custom Schedules. Use Case: There may be a scenario where number of Change Requests that have got closed and the associated incident is still in open ...
Add request API Using Postman
You need to send the TECHNICIAN_KEY and format in Params and the data in Body. Also, you have to encode the body and send it. Please refer to the below for your reference which is sent using postman. Attached is the SAMPLE JSON file Example : ...
Close all associated tasks when a request is closed
Requirement: When a request is closed, it is necessary to close all of its related tasks. Usecase: In an organizational context, a request can involve multiple technicians, resulting in its segmentation into distinct tasks. When the request is marked ...
Setting the Request Due Date as the Schedule End Date for All Associated Tasks
Requirement: Request DuebyDate has to be set as the schedule end date for all the tasks associated to the request. Steps to follow: Goto Admin > Developer Space > Global function > New > Paste the content from the attachment Global function_4.txt and ...
How to populate request details on associated tasks.
This sample script is used to update request field values into tasks associated with request templates The Request details are stored as a JSON Object in a file and its path is provided as input to the Script. This can be used in the application ...