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

Mark Manders
Mega Patron

Can you share your client script, because that's usually the way to go.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Mark,

 

Below is onload client script 

function onLoad() {
    // Get the HR Service value
    var hrService = g_form.getValue('hr_service');

    // Check if the HR Service is "Anonymous Reports"
    if (hrService == 'Anonymous Report') {
        // Hide the state field
        g_form.removeOption('state', 20);
    }
}

Anand Kumar P
Giga Patron
Giga Patron

Hi @SiddharthG55401 ,

 

function onLoad() {

    // Check if the Service field has the value "Anonymous Report"

    if (g_form.getValue('hrservice filed backendname') === 'Anonymous Report') {// replace hr service filed backnd name and anonymous report value 

        g_form.removeOption('state', ‘Awaiting acceptance choice value ');// 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

Hi Anand, thanks for your reply, but this script is not working as expected.

SiddharthG55401_1-1734343243070.png