Want to hide 'Awaiting Acceptance' from the state for the 'Anonymous Report' HR service

SiddharthG55401
Tera Contributor

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

SiddharthG55401_0-1734337075513.png

 

1 ACCEPTED SOLUTION

@SiddharthG55401 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

13 REPLIES 13

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

@SiddharthG55401 Did you tired above script its working fine in my pdi

@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!

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);

 

} }

Ankur Bawiskar
Tera Patron
Tera Patron

@SiddharthG55401 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader