Record Producer- MRVS

Gaurav69
Tera Contributor

Hii... I have created a Table ABC having a field Crisis Country (ref -Country table) and then created 10 records with initial ten countries. so now they are my crisis countries. Then i created Record Producer (named Crisis Country) in this I have MRVS variables

1. Variable country - country table

2. Priority -  choice type ( standard and emergency)

Now i want that if i select a country in vaiable country field and if that country belongs to my crisis country list then the priority should change to emergency and if not then priority should be standard. 

How to configure it using client script and script include.

2 REPLIES 2

palanikumar
Mega Sage

Try creating a Client script on change of the country field. Use Glide Ajax and verify whether the country belong to crisis country, if yes then mark the priority field as emergency 

Thank you,
Palani

Dnyaneshwaree
Mega Sage

Hi @Gaurav69 ,

Please try below code and made changes according to your requirement:

Script include: (client callable)

getCrisisCountries: function(){
        var returnObj = {};
        var countrysysID = this.getParameter('sysparm_countries');
        var grCountry= new GlideRecord('ABC'); // use your table
        grCountry.addQuery('sys_id', countrysysID);
        grCountry.query();
        if (grCountry.next()) {
            returnObj.countryName = grCountry.getValue('country_name'); // use your field name
        }
        return JSON.stringify(returnObj);

Catalog client script: (On change - country variable)

 var countrysysID = g_form.getValue('country_name'); // please use variable name as per your requirement

    var gaIC_Get_user_values = new GlideAjax("ABC"); // use your script include name
    gaIC_Get_user_values.addParam("sysparm_name", "getCrisisCountries");
    gaIC_Get_user_values.addParam("sysparm_user", countrysysID);
    gaIC_Get_user_values.getXML(setPriority);

    function setPriority(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        var userObject = JSON.parse(answer);

        if (userObject.countryName) {  // change condition as per your requirement
            g_form.setValue("priority", "emergency"); // update name of priority variable and values as per your requirement
        } else {
            g_form.setValue("priority", "standard"); // update name of priority variable and values as per your requirement
       
    }

Mark it Helpful and Accept Solution!! If this helps you to understand.

Thanks in advance!!
Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru