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.

help text (label variable) is not visible on the service portal based on the drop down changes ?

karishma shaik
Tera Contributor

Hi All,

 

I have a urgent Requirement, Help text (label variable) is not Visible on service portal based on drop down changes,

Example : I have drop down variable in service catalog, in drop down x and y choices when i am selecting x, (label variable) help text  is should be not visible , when i am selecting the y help text should be visible on service portal and itil view also, but it's not working as excepted 

I have written on change catalog script :

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    if (newValue == 'vendor') {
        alert('test');
        g_form.showFieldMsg('payments_label', 'Please search invoice in the Report/SearchReport/Search tab in My Payables before submitting ticket.', 'info', true);
    } else {
        g_form.hideFieldMsg('payments_label', 'Please search invoice in the Report/SearchReport/Search tab in My Payables before submitting ticket.');
        }
    }
Can you please correct me anyone, please help me on this .
thanks,
1 REPLY 1

Community Alums
Not applicable

Hi @karishma shaik ,

 

Use g_form_getField("<fieldname>").placeholder to change the example text dynamically in a portal.

Use g_form.getControl("<fieldname>").placeholder to change the example text dynamically in the Now platform.

Please try the below code-

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var infoField = g_form.getField("payments_label");

    if (newValue == 'vendor') {
        infoField.expand_help = true;
        infoField.instructions = "<p>Please search invoice in the Report/SearchReport/Search tab in My Payables before submitting ticket.</p>";
    } else {
        infoField.expand_help = true;
        infoField.instructions = "<p></p>"; // Clear the help text by setting an empty paragraph
    }
}

 

 

Or try this-

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

    var infoField = g_form.getField("payments_label");

    if (newValue == 'vendor') {
        infoField.expand_help = true;
        infoField.instructions = "<p>Please search invoice in the Report/SearchReport/Search tab in My Payables before submitting ticket.</p>";
        infoField.help_tag = "More information";
    } else {
        infoField.expand_help = true;
        infoField.instructions = "<p></p>"; // Clear the help text by setting an empty paragraph
        infoField.help_tag = "";
    }
}

 

If the above doesn't work try to take a look into these below posts-

Can you please try to take a look into the below posts-

https://www.servicenow.com/community/developer-forum/change-help-text-dynamically-based-on-a-value/m...


https://www.servicenow.com/community/developer-forum/how-to-make-help-text-display-conditionally/m-p...

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar