Display name based on condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2024 11:18 PM
Hi community I have catalog client script running on this record producer when the first variable is Are you logging this incident for someone else (yes/no)? it is no it should show the name of the logged in person but if yes it should its doing that in the backend but not on the portal.
Portal
Backend
Catalog client script (Onchange client script)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 12:33 AM
Hi @Chirag Pathak please try below one
if(isLoading || newValue=='Yes'){
g_form.clearValue('caller_id');
}else if(newValue=='No'){
g_form.setValue('caller_id',g_user.userID());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 12:38 AM
Hi @Chirag Pathak ,
Please update your code with below code and it will work fine.
g_form.setValue('caller_id', g_user.userID);
To fetch the current logged_in user in client script you can use g_user.userID.
You can refer the below link to have clear understanding of "The GlideUser (g_user) Class"
Kind Regards,
Bihung Basumatary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 12:38 AM
Try cache.do once may be this is the issue.
or try to create script on another catalog item , just to test.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 12:55 AM
Hi @Chirag Pathak, g_user.userID will get the sys_id of the current user in client script.
g_form.setValue('caller_id', g_user.userID);
Regards,
Sunil