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 message on LIST collector variable based on condition

snow34
Tera Contributor

I have variable named called as "Environment" type of this variable is list collector , in this collector i have three values DEV, IST, PROD so whenever PROD is selected i want to show , show field message .

 

Please help me with this as this is very urgent

7 REPLIES 7

Hi  @snow34 

Check this:

 

 

function onChange(control, oldValue, newValue, isLoading) {
    // Exit if the form is still loading
    if (isLoading || newValue === '') {
        return;
    }

    // Split the newValue into an array (List Collector returns a comma-separated list)
    var selectedValues = newValue.split(',');

    // Iterate over the selected values and show a message if 'PROD' is found
    for (var i = 0; i < selectedValues.length; i++) {
        var value = selectedValues[i].trim(); // Trim any extra whitespace

        if (value == 'PROD') {
            // Show an info message box on the 'Environment' field
            g_form.showFieldMsg('environment', "You have selected the PROD environment.", 'info', false);
            break; // Exit loop early if 'PROD' is found
        }
    }
}

 

……………………………………………………………………………………………………

Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand. 

I tried this but no luck

Akash4
Kilo Sage

Seems there is a bug with ShowFieldMsg and ShowErrorBox. The older and prior Problems are seen here:

1. https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0727748

2. https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0675031

3. https://noderegister.service-now.com/kb?id=kb_article_view&sysparm_article=KB0782155

Maybe a KB Article might be on the way!! 

Hope this helps!
Regards, Akash
Please mark it as helpful 👍 or Accept Solution ✔️ based on the response to your query.

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.