UI Action Send for Approval

Avinash Dubey2
Tera Contributor

I want to create an Ui Action :

Send for approval

  • This will be visible when status is draft and record is not new.
  • After clicking on this button status changes to pending for approval and assignment group must be filled with "service desk" and an approval will be sent to "service desk" group. Once approval is approved status should be Work in progress.

I have written the following code :But the assignment group is not saving to when service desk is configured from this code.I dont know how to implement "an approval will be sent to "service desk" group".

function SendforApproval() {

    if (g_form.getValue('u_status') == '2'); {
        g_form.setValue('u_status', '4');
        g_form.setValue('assignment_group', 'Service Desk');
        g_form.update();
        gsftSubmit(null, g_form.getFormElement(), 'SendforApproval');

    }
}
if (typeof window == 'undefined')
    serverResolve();

function serverResolve() {
    current.incident_state = IncidentState.RESOLVED;
    current.state = IncidentState.RESOLVED;
    current.resolved_by = gs.getUserID();
    current.update();
}

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update everything in server side since you are anyhow updating it in server function

function SendforApproval() {

	if (g_form.getValue('u_status') == '2') 
		gsftSubmit(null, g_form.getFormElement(), 'SendforApproval');
}

if (typeof window == 'undefined')
	serverResolve();

function serverResolve() {

	current.setValue('u_status', '4');
	current.setDisplayValue('assignment_group', 'Service Desk');

	current.incident_state = IncidentState.RESOLVED;
	current.state = IncidentState.RESOLVED;
	current.resolved_by = gs.getUserID();
	current.update();
}

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Mahendra RC
Mega Sage

Hello Avinash,

I could see that [Action name] is blank in screenshot you attached. Please update the action name as SendforApproval in [Action name] field on your UI action record.

Please mark this helpful/correct, if it answer your question.

Thanks