- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 10:19 AM
Hi Team,
How to populate the description and picture of the selected record in the catalog item
EX:
I am having catalog item in that I am having a reference field(cmdb_hardware_product_model), when we select any record in that refence field, that record description and picture should populate below of the reference field.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 11:17 AM - edited 09-23-2024 11:17 AM
Hi @Gopal14
On selection of a Catalog, you need write an On change client script and call GlideAjax to the script include to get the value.
Client script:
Type: On change
Variable: hardware_model
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
g_form.clearValue('description'); // Clear the value when another model is selected
var ga = new GlideAjax('HardwareModel'); // Calling the script include
ga.addParam('sysparm_name','description'); // calling the method
ga.addParam('sysparm_model',newValue);
ga.getXML(answer);
function answer(response){
var value = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('description',value); // populating the description
}
}
Script Include:
Client callable : True
Name: HardwareModel
var HardwareModel = Class.create();
HardwareModel.prototype = Object.extendsObject(AbstractAjaxProcessor, {
description : function() {
var model = this.getParameter('sysparm_model'); // get the sys_id from the script
var gr = new GlideRecord('cmdb_hardware_product_model');
gr.addQuery('sys_id',model);
gr.query();
if(gr.next()){ // if sys_id found, return the description
return gr.description;
}
},
type: 'HardwareModel'
});
If this information helps you, Kindly mark this post as helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 12:01 AM
Hi @Gopal14 ,
You should show that value in some variable, so you need to create a field description.
I believe there is no field which can store Image on the catalog form.
If the above script helps you, Kindly mark it as Helpful.
Regards,
Najmuddin.