Return to Requestor UI action on approvals

Michelle Kelly
Kilo Contributor

Hi all, Please help.

I have created a custom ui action on the approvals "return to requestor" same logic as reject only when clicked it should make a checkbox "u_return_to_requestor" on the approval record true. I have included logic in my RITM workflow to check if true create task to requested by to provide more info and resubmit. - This works as expected.

Issue: u_return_to_requestor checkbox becomes true when I enter the comments first and then click return to requestor ui action but not if I click the return to requestor ui action first if appears on the form as true but return false in my logic. So I have to be missing an update in my logic somewhere but when I include a 2nd current.u_return_to_requestor = 'true';  current.update(); (see screenshots below) when I enter the comments first and then click return to requestor ui action in my logic u_return_to_requestor returns false.

find_real_file.png

I have tried below:

find_real_file.png

and also this:

find_real_file.png

Logs: 

MK Return to Requestor == trueMK record sys_id: a9faaa461b3d99102338542f0a4bcb97

find_real_file.png

MK Return to Requestor == falseMK record sys_id: bdfaae461b3d99102338542f0a4bcb72

find_real_file.png

Code: 

current.u_return_to_requestor = 'true'; 
current.state = 'rejected';

if (!gs.nil(current.comments))
    current.update();
else {
    gs.addErrorMessage(gs.getMessage("Comments are required when Returning to Requestor for further information. Note: Selecting this option will send a new task to the requesting user for further information."));
    current.state = 'requested';
    current.setAbortAction(true);
    action.setRedirectURL(current);
}

Workflow:

find_real_file.png

find_real_file.png

3 REPLIES 3

suvro
Mega Sage
Mega Sage

Compare your logic with this

find_real_file.png

If I update my logic to above, the same happens only works when I Click return to request first, then Comment but can't get both to work.

Logic:

(function() {
    current.u_return_to_requestor = 'true'; 
    current.state = 'rejected';
    var comments = false;
    if (current.comments.getJournalEntry(1) != undefined) {
        var lastComment = current.comments.getJournalEntry(1);
        var index = (current.comments.getJournalEntry(1) + '').indexOf(gs.getUserDisplayName());
        if (index > -1 && index <= 22)
            comments = true;
    }
    if (!JSUtil.nil(current.comments) || comments) {
        current.update();
        new ApprovalUserFeedback().rejected(current);
    } else {
        gs.addErrorMessage(gs.getMessage("Comments are required when Returning to Requestor for further information. Note: Selecting this option will send a new task to the requesting user for further information."));
        current.state = 'requested';
        current.setAbortAction(true);
    }
})();

Results:

Comment first, then click return to request

Log: MK Return to Requestor == falseMK record sys_id: f8f57286db399910199dd9fcd3961904

find_real_file.png

 

Click return to request first, then Comment

Log: MK Return to Requestor == trueMK record sys_id: a5e7724adb399910199dd9fcd3961981

find_real_file.png

Brad Lieberg
Tera Contributor

@suvro  or @Michelle Kelly I am attempting to utilize the same process. The issue I am running into is once the approval is "returned to requestor" the ritm does no update the approval status to rejected (actually it goes from requested to not yet requested). If I manually change the approval on the ritm to rejected everything works as expected. Also if I simply reject or approve everything works as expected.

Have you seen this or have an idea what might be causing it? I wouldn't think its a business rule or anything as technically its just rejecting the approval.