- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2020 01:15 AM
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,
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.
Please suggest me on this.
Thanks,
Varma
Solved! Go to Solution.
- Labels:
-
Incident Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2020 06:36 AM
@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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2020 01:54 AM
Hi,
approach will be the same.
onChange of that string variable use GlideAjax and query the software model table to check those 2 checkboxes
Based on that set the 2 variables
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2020 02:14 AM
Hi Ankur,
could you please suggest code. That will be very helpful.
Thanks,
Varma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2020 02:33 AM
Hi,
sample below
Script Include: It should be client callable
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var name = this.getParameter('sysparm_name');
var obj = {};
var gr = new GlideRecord('software model table'); // give proper table name here
gr.addQuery('field', name); // use valid field name here
gr.query();
if(gr.next()){
obj["pre"] = gr.pre_installation.toString();
obj["post"] = gr.post_installation.toString()
}
JSON.stringify(obj);
},
type: 'checkRecords'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_name', g_form.getValue('build_version')); // give here valid variable name
ga.getXMLAnswer(function(answer){
if(answer != ''){
var parser = JSON.parse(answer);
g_form.setValue('pre_variable', parser.pre); // give here valid variable name
g_form.setValue('post_variable', parser.post); // give here valid variable name
}
});
//Type appropriate comment here, and begin script below
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2020 04:36 AM
Hi Ankur,
Thanks for you help,
I have tried the above code but its triggering error like this ''There is a JavaScript error in your browser console''
And also i came to know ''Build version '' value is not change its constant.
Below screenshot which i configured
Client script:
With referencing any variable cant we get the field value?
Please suggest,
Thanks,
Varma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2020 04:58 AM
Hi,
Are you querying with proper field on software model table?
User is giving build version and you are trying to search in that field?
Try adding alert what came in answer
alert(answer);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
