Based on checkbox field value, I need to set variables value true or false?

varma2
Mega Sage

Hi All,

We have software model published catalog items and all the software models stored in ''cmdb_software_product_model'' table.

In this table we have two check box 1 is pre installation 2nd is post installation. please refer the below screenshot of both fields,

find_real_file.png

 

We have catlog items in these models and we have a two variables same as pre installation and post installation.

If above fields is checked in software model  it will need to show below variable as a TRUE and if field not checked it will show false in below variables.

find_real_file.png

Please suggest me on this.

 

Thanks,

Varma 

1 ACCEPTED SOLUTION

@varma

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark my response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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

View solution in original post

19 REPLIES 19

Hi Ankur,

 

Yes i have set both values correctly. But as i said in both fileds any on of them is unchecked, value set in both variables false.

I dont why both are set false, even one of the field is checked. its should set one is true another one false.

 

Thanks,

varma

 

Hi,

check what comes in the data[4] and data[5]

Regards
Ankur

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

@varma

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark my response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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

Hi Ankur,

 

Since my code not working for few scenarios im trying with your script.

 

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

var ga = new GlideAjax('checkRecords');
// alert('modelnum'+pre);
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_name', g_form.getValue('Installation_type')); // give here valid variable name
ga.getXMLAnswer(function(answer){
if(answer != ''){
var parser = JSON.parse(answer);
alert(answer);
alert('modelnum'+pre);
g_form.setValue('preinstalation', parser.pre); // give here valid variable name
g_form.setValue('post_installation', parser.post); // give here valid variable name
}
});
}

 

When i give alert it showing Null Value.

 

Please suggest,

Thanks,

Hari

Hi,

null means nothing is returned from script include or script include not getting called

Regards
Ankur

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