- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 12:18 AM
Hi Team,
I want to remove the 'Awaiting Acceptance' option from the state for the Anonymous report in HRSD. I tried creating an onLoad Client Script, but it's not working properly. Please let me know the steps and script for removing 'Awaiting Acceptance' for the Anonymous report.
Thankyou
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 02:11 AM
or you can use sysId of that hr service
function onLoad() {
// Get the HR Service value
var hrService = g_form.getValue('hr_service');
// Check if the HR Service is "Anonymous Reports"
if (hrService == 'sysIdHRService') {
// Hide the state field
g_form.removeOption('state', 20);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 02:05 AM - edited 12-16-2024 02:10 AM
Hi @SiddharthG55401 ,
function onLoad() {
// Check if the Service field has the value "Anonymous Report"
var hrService= g_form.getDisplayBox('hr_service').value; //Hr service field is refrence convert to string then compare
if (hrService === 'Anonymous Report') {
g_form.removeOption('state', 20);// replace state filed backend name and choice value name
}
}
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 04:33 AM
@SiddharthG55401 Did you tired above script its working fine in my pdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 04:39 AM
@Anand Kumar P , I try the script but it's not working fine for HR services application.
Have you tried this script for HR services? Please let me know if it's working for you for HR services as well. Thankyou!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 04:52 AM - edited 12-16-2024 05:03 AM
Do one thing open the hr form and fill details for hr service and state then click ctrl+shift +alt+j Run code button in keyboard and pate below code check what values your getting in alerts
var hrService= g_form.getDisplayBox('hr_service').value;
alert(hrService);//check getting value as Anonymous Report exactly
if (hrService === 'Anonymous Report') { g_form.removeOption('state', 20);
} }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 02:09 AM
this will work
function onLoad() {
// Get the HR Service value
var hrService = g_form.getDisplayBox('hr_service');
// Check if the HR Service is "Anonymous Reports"
if (hrService == 'Anonymous Report') {
// Hide the state field
g_form.removeOption('state', 20);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader