Compare 2 values and check even if it's case sensitive

Jake Adams
Tera Contributor

Hi,

 

I am using a client callable script include to compare a value from 'Server' to the one entered in a 'Variable' and if it matches I want to restrict it and clear the variable field, which is working fine.

 

For eg: If the value on Server is ABC and I enter ABC in the Variable it will clear the variable, but if the value on Server is ABC and I enter abc or Abc in the Variable it will accept it. How do I make this check and make it work even if the values entered are case sensitive? 

6 REPLIES 6

Update you script include to 

 

var AppName = Class.create();
AppName.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getAppDetails: function(app) {
var response = {};
var que = this.getParameter('sysparm_app_name');
var gr = new GlideRecord('question_choice');
gr.addEncodedQuery('question=103d1e4bdb3d9810c69960d444961966');
if (gr.get(que))
{
var val = gr.getValue('value');
response.value = val;
}
return JSON.stringify(response);
},
type: 'AppName'
});

 

 

And client script to

 

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

var newValueSmall = newValue.toLowerCase();

var ga = new GlideAjax('AppName');
ga.addParam('sysparm_name', 'getAppDetails');
ga.addParam('sysparm_app_name', newValue);
ga.getXMLAnswer(function(answer) {
var response = JSON.parse(answer);

if (response && newValueSmall == response.value.toLowerCase()) {
g_form.clearValue('app_name');
}

});
}

 

 


Please mark this response as correct or helpful if it assisted you with your question.

Hi,

Still having the same issue not sure why