UI policy on cmdb_ci_ip_switch table

mohanambalnanja
Tera Contributor

Hi All,

 

I am trying to make one specific field mandatory based on the below attached condition. But when I dot walt the location support region field it is not working as expected. 

 

mohanambalnanja_0-1717565198262.png

 

Can someone please advise how I can achieve this and which one is the best way.

 

1. On Change client script based on location support region field change in cmdb_ci_ip_switch table or UI policy 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@mohanambalnanja 

it seems the dot walked condition is not working for you

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sanket Landge
Tera Expert

Hello @mohanambalnanja ,

 

You can use a onChnage() client script

Client Script:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

  if (isLoading || newValue === '') {

   return;

  }

      var dType = g_form.getValue("device_type");

      var fType = g_form.getValue("functional_type");

      var location =g_form.getValue("location");

       var resion;

 

  var ga = new GlideAjax("Utils");

  ga.addParam ("sysparm_name", "getResion");

  ga.addParam("sysparm_location",location);

  ga.getXMLAnswer(response);

 

  function response(answer){

  resion = answer;

  //do your validation here

  }

}

 

Script Include:

var Utils = Class.create();

Utils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

 

 getResion: function(){

    var sysId = this.getParameter('sysparm_location');

    var gr = new GlideRecord("cmn_location");

    gr.addQuery("sys_id", sysId);

   gr.query()

    if(gr.next()){

    return gr.support_resion;

  },

 

type: "Utils"

});