How to auto populate short description and description in request based on RITM catalog item name

ashok17
Tera Contributor

how to auto populate short description and description in request based on RITM catalog item name in serviceNow.

I have tried Business rule but it's not's works, Please suggest if any one have idea for this.

 

1 ACCEPTED SOLUTION

swathisarang98
Giga Sage
Giga Sage

Hi @ashok17 ,

 

You can write a onload client script on sc_request table and call script include,

please refer below for working solution,

Script include

swathisarang98_0-1709133765981.png

 

var getShortDescription = Class.create();
getShortDescription.prototype = Object.extendsObject(AbstractAjaxProcessor, {


    getDeatil: function() {

        var sysId = this.getParameter('sysparm_id');

        var getRitmRecord = new GlideRecord('sc_req_item');
        getRitmRecord.addQuery('request', sysId);
        getRitmRecord.query();
        if (getRitmRecord.next()) {
			gs.info('line number ');
            var itemName = getRitmRecord.cat_item.getDisplayValue();
            gs.info('line number 14' + itemName);
        }
        return itemName;
    },



    type: 'getShortDescription'
});

 

Client script:

swathisarang98_1-1709133849921.png

 

function onLoad() {
   
   var sysId = g_form.getUniqueValue();
   alert(sysId);

	var gr = new GlideAjax('getShortDescription');
	gr.addParam('sysparm_name','getDeatil');
	gr.addParam('sysparm_id', sysId);
	gr.getXML(getResponse);   
}
function getResponse(response){
	var ans = response.responseXML.documentElement.getAttribute('answer');
	alert(ans);
	

		g_form.setValue('short_description',ans);
		g_form.setValue('description','Testing Description');
	

}

 

 

Please let me know if it does not work for you and please comment or remove logs.

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang

View solution in original post

4 REPLIES 4

Vaibhav_Nikam
Tera Guru

Hi @ashok17 
I hope the given link makes your problem solve :


How to Auto populate the values by using Glide Ajax


If my response finds helpful, please indicate its helpfulness by selecting Accept as Solution and Helpful.

Thanks,

Vaibhav Nikam

Thanks for response.

I have attached screenshot also for reference and my current requirement is if end user raise request through self service portal then the catalog item name should be auto populate on description and short description fields in request.

 

Tried Run script workflow activity also but not works for me.

swathisarang98
Giga Sage
Giga Sage

Hi @ashok17 ,

 

You can write a onload client script on sc_request table and call script include,

please refer below for working solution,

Script include

swathisarang98_0-1709133765981.png

 

var getShortDescription = Class.create();
getShortDescription.prototype = Object.extendsObject(AbstractAjaxProcessor, {


    getDeatil: function() {

        var sysId = this.getParameter('sysparm_id');

        var getRitmRecord = new GlideRecord('sc_req_item');
        getRitmRecord.addQuery('request', sysId);
        getRitmRecord.query();
        if (getRitmRecord.next()) {
			gs.info('line number ');
            var itemName = getRitmRecord.cat_item.getDisplayValue();
            gs.info('line number 14' + itemName);
        }
        return itemName;
    },



    type: 'getShortDescription'
});

 

Client script:

swathisarang98_1-1709133849921.png

 

function onLoad() {
   
   var sysId = g_form.getUniqueValue();
   alert(sysId);

	var gr = new GlideAjax('getShortDescription');
	gr.addParam('sysparm_name','getDeatil');
	gr.addParam('sysparm_id', sysId);
	gr.getXML(getResponse);   
}
function getResponse(response){
	var ans = response.responseXML.documentElement.getAttribute('answer');
	alert(ans);
	

		g_form.setValue('short_description',ans);
		g_form.setValue('description','Testing Description');
	

}

 

 

Please let me know if it does not work for you and please comment or remove logs.

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang

Hi Swathi,

Thanks for response.

I have tried Personal Developer Instances few possible approaches in like Business Rule and run script activity but after tried client script also, it's works on PDI also.

Thankyou..