- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 06:23 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 07:25 AM
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
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:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 06:26 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 06:39 AM - edited 02-28-2024 06:40 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 07:25 AM
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
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:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:33 AM
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..