Reuse the approval e-signature for change cancellation process

naresh831
Tera Contributor

How to enforce e-signature validation for change cancellation actions in the same way as Approval/Reject ?

7 REPLIES 7

Yep — that error makes sense.

promptCheck() isn’t a “standard” function that exists everywhere in ServiceNow. It only exists on pages where the OOB eSignature/Approval UI scripts are loaded. Your Cancel UI Action is calling it on the Change form, but that form doesn’t have that script loaded, so the browser throws “promptCheck function not found.”

What to do:

  1. Stop using “approved/approve” (you’re building Cancel).

    • Change sysparm_target_state to your Canceled state value

    • Don’t set the state to approved

  2. Don’t hardcode the sys_id

    • Use: var sysID = g_form.getUniqueValue();

  3. Find where promptCheck is defined and make sure it loads on the Change form

    • Go to System UI → UI Scripts

    • Search the script contents for: function promptCheck

    • Once you find it, you need that same UI script (or UI macro) to be included/loaded on the Change form, otherwise promptCheck() will never exist there.

Quick sanity check you can add right now before calling it:

if (typeof promptCheck !== 'function') {
  g_form.addErrorMessage("eSignature script isn't loaded on this form, so promptCheck() can't run.");
  return;
}

@naresh831 - Please mark as Accepted Solution and Thumbs Up if you found Helpful!!

@Matthew_13   promptCheck is in on Submit Client script on approval table, I've recreated the same client script on Change_request table. Once I enable this client script, when I click cancel button getting onclick client function not available error..

 

naresh831_0-1768132608478.png

naresh831_1-1768132687690.pngnaresh831_2-1768132715061.png

 

It seems there are no UI Scripts/Macros. 

naresh831_3-1768132833151.png

 

Indeed;

promptCheck() is not a global client function. It is loaded and supported only in the approval (sysapproval_approver) context by the Approval with e-Signature plugin.

When the approval onSubmit Client Script is copied to change_request it introduces a client-side error during form load because approval-specific dependencies are not available on the Change form. Once that error occurs, the page fails to register later client functions, which is why the Cancel UI Action throws:

“onclick client function not available”
(runClientCode() never loads).

This is not related to missing UI Scripts or Macros.

To enforce e-signature on Cancel Change, the logic must be implemented directly in the Cancel UI Action or a dedicated shared UI Script not by reusing approvaltable client scripts.

So at the end of day: It must be implemented inside the Cancel UI Action itself basically or via a prebuilt shared UI Script rather than reusing approval table client scripts.

Specifically:

  • Validate e-signature via ESignatureUtils.formUpdateCheck

  • Trigger the e-signature flow if required

  • On success, submit the Cancel UI Action normally

This basically keeps the logic self contained and avoids approval only dependencies.

 

@naresh831 - Please mark as Accepted Solution and Thumbs Up if you found Helpful!!