Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

validate requested for and current logged in user to allow request submission

shyam34
Tera Contributor

Hello All,

I have requirement to abort Request submission when we see "Requested for" and "current logged IN user" are not same , we need to do this because there is an variable to acknowledge terms & conditions and this has to be done by requested for only so we need to avoid on behalf of requests 

Can you please guide/help with Script to achieve this !!

13 REPLIES 13

hello @shyam34 ,

 

what is the java script error that you are getting on the screen ?

you can try this script and write this script in on submit

make sure you selected UI type as all and try 

Screenshot 2022-11-16 at 19.35.29.png

If(g_user.userID == g_form.getValue('your_requested_for_field_name'))
{

    return true;

} 
else
{

    return false;

}

Hope this helps 

Mark my answer correct if this helps you

Thanks

 

 

 

Hello Mohith,

Created same already but still it could not stop submitting the request , it is throwing java script error that g_user.userID() in console logs

can we acheive the same with script include and glide ajax?

 

@shyam34 can you post the screenshot of the exact error that you are getting in console or just paste the line here ?

shyam34_0-1668608419210.png