Error in OOB "Todos Approval Actions" widget in the ESC portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 02:24 AM
Hi All,
I'm getting the following error when an approver tries to approve the HR case record from the portal. The failing widget "Todos Approval Actions" is the OOB widget only. We are facing this issue after upgrading the instance to Sandiego Patch-5 version. Can anyone suggest what might be the issue?
Thanks in Advance.
Regards,
Pallavi T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2022 01:19 AM
The issue was resolved after adding commentId and commentTable variable in the "To-dos task Line Item" widget at line 44, 45 in Server script as shown in the attached image.
Try adding the same lines. It would work for you as well.
Regards,
Pallavi T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2022 01:24 PM
Hello all,
There were many changes to many levels of the Todo's widgets and related cascading widget structure. This was not only designed to allow for granular delegation, but the changes also utilize a number of constants as well and how the data is passed from one widget to another. If you have made any modifications to the OOB widgets at any level in todos', you may see these errors. We copied the page, added the OOB todo's summary widget, tested, and it worked with no errors. You may need to do the same and then add any specific customizations back into your widgets.
Specifically, this is a result of the approvals glide query not actually receiving input data from the parent widget, so the query fails (line 50-ish) in the Todos Approval Actions widget, but the customizations could be as high up as the HRM Todos Summary widget.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2022 03:43 PM - edited ‎10-20-2022 03:49 PM
This issue has been associated to the problem PRB1583635. The workaround for these errors are to repace line 69 with return activityStreamGr.comments && activityStreamGr.comments.canWrite(); for the script include "Todos Approval Actions".
After changing that there is an error that will pop up regarding line number 113 for the same widget.
Then comment out line 113 and 114 placed under those lines:
if(commentGr.comments) {
var journalEntryComment = commentGr.comments.getJournalEntry(1);
data.comment = journalEntryComment.replace(dateRE, '').toString();
Or the second option is to upgrade the Employee Center Core plugin to version 26.0.4 as that version has these changes.
I recommend this option.
Which is my HI ticket response. But it is the answer for line 69, which is little different.
There are many pieces related. My strong recommendation is to upgrade your Employee Sevice Center COre upgrade to version 26 if you have not done it.
Version 26 contains the server code for that widet, please compare what you have now and apply this new Server script to the widget 'Todos Approval Actions'
(function() {
data.CONST = {
i18n: {
PLACEHOLDER_MESSAGE: gs.getMessage("If you are rejecting the request, provide the reason here."),
REJECT_MODAL_TITLE: gs.getMessage("Reject Request"),
REJECT_MODAL_MESSAGE: gs.getMessage("Please provide a reason for rejecting the request"),
REJECT_MODAL_CANCEL: gs.getMessage("Cancel"),
REJECT_MODAL_SUBMIT: gs.getMessage("Reject Request")
},
ACTION: "updateApprovals",
REJECT_STATE: "rejected",
APPROVED_STATE: "approved",
REQUESTED_STATE: "requested",
APPROVAL_TABLE: "sysapproval_approver"
};
var approvalGr = null;
var commentGr = null;
if (input && input.action === data.CONST.ACTION) {
approvalGr = getTargetRecord(input.approvalId, data.CONST.APPROVAL_TABLE);
commentGr = getTargetRecord(input.commentId, input.commentTable);
data.isPosted = false;
data.requireRejectionComment = checkRejectionCommentRequired(commentGr);
data.useCommentBox = input.useCommentBox && data.requireRejectionComment;
if (updateApprovalAndComment(input.request) && commentGr)
getPostApprovalInfo();
} else if (options && options.sysId && options.commentId && options.commentTable) {
approvalGr = getTargetRecord(options.sysId, data.CONST.APPROVAL_TABLE);
commentGr = getTargetRecord(options.commentId, options.commentTable);
data.isPosted = false;
data.approvalId = options.sysId;
data.commentId = options.commentId;
data.commentTable = options.commentTable;
data.requireRejectionComment = checkRejectionCommentRequired(commentGr);
data.useCommentBox = options.useCommentBox && data.requireRejectionComment;
if (approvalGr && commentGr && approvalGr.state.toString() !== data.CONST.REQUESTED_STATE)
getPostApprovalInfo();
}
/**
* Gets the approval record given a sys id
* @Param {String} sysId The sys_id of the approval record
* @Param {String} tableName The name of the record's table
* @return {GlideRecord} A glide record with the approval
*/
function getTargetRecord(sysId, tableName) {
var targetGr = new GlideRecord(tableName);
data.shortDescription = "";
if (targetGr.get(sysId) && targetGr.canWrite())
return targetGr;
else {
gs.error("Could not find approval record");
return null;
}
}
/**
* Checks user write permissions to determine whether or not a rejection comment
* is required from them to update the approval state
* @Param {GlideRecord} activityStreamGr The record to check if comments can be written
* @return {Boolean} True if comment is required, false otherwise
*/
function checkRejectionCommentRequired(activityStreamGr) {
if (!activityStreamGr) {
gs.error("Could not find Activity Stream record");
return false;
}
return activityStreamGr.comments && activityStreamGr.comments.canWrite();
}
/**
* Updates the state of the approval
* @Param {Object} request An object describing the update request
* @return {Boolean} Returns true on successful update, false otherwise
*/
function updateApprovalAndComment(request) {
if (request.state === data.CONST.REJECT_STATE) {
if (data.requireRejectionComment && data.useCommentBox && !request.comments) {
gs.addErrorMessage(gs.getMessage("Provide the reason you are rejecting the request in the comments field."));
return false;
} else if (request.comments) {
commentGr.comments = gs.getMessage('Reason for rejection: {0}', request.comments);
commentGr.update();
}
} else if (request.state === data.CONST.APPROVED_STATE) {
if (request.comments) {
commentGr.comments = gs.getMessage('Reason for approval: {0}', request.comments);
commentGr.update();
}
} else
return false;
// Set state and update
approvalGr.state = request.state;
if (approvalGr.update()) {
var displayMessage = gs.getMessage("You {0} this request", request.state);
gs.addInfoMessage(displayMessage);
return true;
} else {
gs.addErrorMessage(gs.getMessage("Could not update approval record."));
return false;
}
}
/**
* Sets the last comments and timestamp of the approval to data
*/
function getPostApprovalInfo() {
data.isPosted = true;
data.caption = gs.getMessage("The request was {0}", approvalGr.state.getDisplayValue());
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
if(commentGr.comments) {
var journalEntryComment = commentGr.comments.getJournalEntry(1);
data.comment = journalEntryComment.replace(dateRE, '').toString();
}
data.timeStamp = approvalGr.sys_updated_on.toString();
}
})();