I'm trying to automatically add an approval stage in my code, but it doesn't seem to be working as expected
Here's the code I'm using:- approvalJson = Collection();
- approvalStages = Collection();
- returnObj = Map();
- template_name = requestObj.get("template").get("name");
- // Replace department with UDF_REF3 field which is a lookup field
- approver = requestObj.get("UDF_REF3").get("name");
- // Get the approver email from the lookup field
- approver_email = approver.get("email");
- if (!"null".equalsIgnoreCase(approver)) {
- // Only add stage1 which will be sent to the user lookup field mentioned above
- stage1 = {"StageOne": [approver_email]};
- approvalStages.put("StageOne", [approver_email]);
- approvalJson.put("approval_stages", approvalStages);
- }
- if (!approvalJson.isEmpty()) {
- approvalStages = approvalJson.get("approval_stages");
- input_data = {
- "INPUT_DATA": approvalStages,
- "OPERATIONNAME": "SET_APPROVAL_STAGE",
- "send_immediately": "True"
- };
- operations = Collection();
- operations.insert(input_data);
- returnObj = {"operation": operations, "result": "success"};
- } else {
- returnObj = {"result": "success"};
- }
- return returnObj;
The goal is to add an approval stage automatically based on a lookup field called UDF_REF3. However, the code doesn't seem to be functioning as expected, and no approval stages are being added. I've verified that the lookup field is correctly fetched and the email address is extracted.
I'd appreciate any insights or suggestions on what could be causing the issue or any potential improvements to the code.
Thank you!
New to ADSelfService Plus?