Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Override reference qualifier

traviswarren
Kilo Expert

I am attempting to create an OnChange Client Script that will change the value of the specific Override Reference Qualifier from True to False. The only trouble I have is the syntax to change this value when a specified condition is true. Below I will give you my attempts to access this variable and hopefully someone can lead me in the correct direction.

I believe the one liner should be something like this...

Attempt 1: task.cmdb_ci.sys_dictionary_override.reference_qual_override="false";
Attempt 2: sys_dictionary_override.sc_req_item.cmdb_ci.reference_qual_override = "false";
Attempt 3: sys_dictionary_override.sc_req_item.cmdb_ci.reference_qual_override = 'false';

Thank you in advance.

13 REPLIES 13

I came a little short with your approach. I am probably not calling the function correctly or simply not working. I can document what I have currently.

I have a onChange Client Script on the sc_req_item table, field name CI Class that will change the CI to CI NOT found when the CI Class is = CI Not Found. Also, listens to where the CI Class to is the Value "None". I tested the script with an alert and the condition for if(CI_Class=="None") does work. Below is my Client Script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (!isLoading){
if(newValue != '') {
var CI_Class = g_form.getValue('u_ci_class');
var CI = g_form.getValue('cmdb_ci');
var CI_Not_Found = "c0aa269d613b54003aff006d8225b8d6";
var CINone = new CIClassFalse();
if(CI_Class=="cmdb_ci_CI_Not_Found")
{
//alert(CI_Class);
g_form.setValue('cmdb_ci', CI_Not_Found);
}
if(CI_Class=="None")
{
//alert("Hey!");
CINone.CIClassfunction();
}
}
}
}

My Script Include should set the Value of the override from true to false. I tested this in a background script and it works. Script include is below.

function CIClassfunction() {
var gr = new GlideRecord("sys_dictionary_override");
gr.addQuery('reference_qual_override','true');
gr.addQuery('name','sc_req_item');
gr.addQuery('element','cmdb_ci');
gr.query();
while (gr.next())
{
gr.setValue('reference_qual_override', 'false');
gr.update();
}
}

I may be calling the function wrong. Any assistance will be appreciated.

Thank you


Thank you for all of your assistance. After discussing with my coworker, he explained that adding a reference qualifier would act like an onChange condition where it checks every time you click on the magnify glass or type in the reference field.

Had a little bump in the road with syntax but after all everything worked out as planned.


Thanks so much.


traviswarren
Kilo Expert

I am more aiming this direction but still currently not able to change he value.


var gr = new GlideRecord("sys_dictionary_override");
gr.addQuery('reference_qual_override','true');
gr.addQuery('name','sc_req_item');
gr.addQuery('element','cmdb_ci');
gr.query();
while (gr.next())
{
gr.setValue('reference_qual_override', 'false');
}


TJW2
Mega Guru

Do you still need the Override Reference Qualifier, what about removing it?


Yes. The Override Reference Qualifier changes the original Reference Qualifier set. For a specific condition during my onChange client script I would like the Override Reference Qualifier off.

Please read below for a better understanding.