How to populate the description and picture of the selected record in the catalog item

Gopal14
Tera Contributor

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.

 

1 ACCEPTED SOLUTION

Najmuddin Mohd
Mega Sage

Hi @Gopal14 

NajmuddinMohd_0-1727114932700.png


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.

View solution in original post

5 REPLIES 5

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.