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

@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

Hi Ankur,

Thanks for your quick response, but the above script is not working as excepted 

SiddharthG55401_1-1734351927552.pngSiddharthG55401_2-1734351972158.png

 

@SiddharthG55401 

why your client script is in global scope?

the table is not from global scope

Did you check it's going inside the IF statement for comparison of sysId?

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

Alternative, UI Policy with the 'On Load' checkmark can be created instead of OnLoad Client Script where the condition is 
'HR Service' 'is' 'Anonymous Reports'

Then in the script field

 g_form.removeOption('state', 20)