Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Show field msg

nameisnani
Mega Sage

Hi Team ,

 

can anyone please provide me the script for field msg 

 

when ever - Yes , data owner ....... is selected , field msg should display Please attach evidence or provide details in the description for the existing standing approval '

nameisnani_0-1730263833075.png

nameisnani_1-1730263909950.png

option backend value 

 

please provide me scirpt with output.

1 ACCEPTED SOLUTION

@nameisnani You didn't replace with variable name but with select text. Should be as below.

 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    if (newValue === 'yes2') {
        g_form.showFieldMsg('does_the_request_owner_approval_not_required_as_standing_approval_in_place', 'Please attach evidence or provide details in the description for the existing standing approval', 'error');
    } else {
        g_form.hideFieldMsg('does_the_request_owner_approval_not_required_as_standing_approval_in_place', true);
    }
}

 

 

Make an onChange client script on variable "does_the_request_owner_approval_not_required_as_standing_approval_in_place"

."

HitoshiOzawa_0-1730267708884.png

 

Execution result.

HitoshiOzawa_1-1730267857232.png

 

View solution in original post

6 REPLIES 6

Hey @nameisnani 

You're putting the Label (Text) of the question choice. (Yes - Data owner... in place).

The <your_variable_name> means the variable name of "Does the request include sensitive Data Elements?". 

So let open the variable, and you will figure it out the variable name like below.

Timi_0-1730267671368.png

 

You can also try the UI Policy suggestion below from Ashish without any lines of code.

 

Cheers,

Tai Vu

Ashish Parab
Mega Sage
Mega Sage

Hello @nameisnani ,

Instead of using a script, you can achieve this with a UI Policy.

 

ashish_parab_0-1730265454299.png

 

ashish_parab_1-1730265476020.png

 

ashish_parab_2-1730265494898.png

Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.

 

Thanks and Regards,

Ashish