- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2023 11:07 PM
Hello Community members,
I am learning scripting in ServiceNow & stuck in setting condition to check whether the 'Caller (caller_id)' of respective incident is 'VIP' or Not, if 'VIP' then display a field msg. on 'Form View of Agent Workspace'. if false (i.e., Not VIP) then no need to Display the VIP field msg.
For this, created an onload CS on Incident table, View- workspace (Global-false), UI type- All, Isolated script- check,
Script-
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.showFieldMsg('caller_id','VIP','info');
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2023 11:34 PM - edited ‎02-09-2023 11:37 PM
Hi @rishabh31 ,
Try the below script. This should server your purpose:
g_form.getReference("caller_id",checkIfVIP);
function checkIfVIP(user){
if(user.vip == "true")
g_form.showFieldMsg("caller_id","This user is a VIP user","info") //Change your field msg content
else
g_form.hideFieldMsg("caller_id")
}
I hope this helps.
Please hit Helpful if this helps you and Accept the response if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2023 11:46 PM - edited ‎02-09-2023 11:48 PM
hello @rishabh31 ,
Allow client script to work on AGENT WORK SPACE FORM VIEW and add below code
var caller = g_form.getReference('caller_id',callerinfo)// callerinfo is an callback function
function callerinfo(){
if(caller.vip==true){
g_form.showFieldMsg('caller_id','VIP','info');
}
else{
g_form.hideFieldMsg('caller_id')
}
}
Regards,
Shyamkumar