- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2017 08:06 AM
i have done some research and have found out that New call uses "CallTypeChanged to Request" Business rule to pass some variables to the request form. I would like to pass okthe short description from new call to the request. i have tried to add the short descritpion to the URL in the business rule but not luck when the request is created as i doesnt pull the short description.
i would appreciate any help on this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 08:52 AM
Ok we have two predefined business rules involved here,
1. CallTypeChanged to Request on New Call table ( This will send comments which have description in it, we need to add short description to comments variable)
Original:
var comments = "NEW_CALL_REF:"+current.sys_id+" "+current.description;
should be changed to
Modified:
var comments = "NEW_CALL_REF:"+current.sys_id+" "+current.description+" SHORT_DESC "+ current.short_description;
2. Link back to the call that generated it on Request(sc_request) table ( This will consume data sent by above business rule)
Original:
var full_text = current.special_instructions;
var call_id = full_text.substring(13,45); //Extract the call_id
var real_desc = full_text.substring(46,full_text.length); //Extract the actual message
current.special_instructions = real_desc;
should be changed to
Modified:
var full_text = current.special_instructions;
var call_id = full_text.substring(13,45); //Extract the call_id
var indx = full_text.indexOf('SHORT_DESC');
var real_desc = full_text.substring(46,indx);
var s_desc = full_text.substring(indx,full_text.length);
current.short_description=s_desc;
current.special_instructions = real_desc;
Please add above modified code in place of original, it will bring short description from new call to request
P.S: Hit like, Helpful or Correct depending on the impact of the response
Thanks,
Sai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2017 06:33 PM
Setting a value via URL requires a little more work in a catalog item/record producer, but luckily there's a really great SNCGuru article called Parse URL Parameters in a Client Script that I've use many, many times to accomplish this.
For this method, you add some sort of parameter to the end of the url of the catalog item. In this case, you can pass the sys_id of a user with the sysparm_user parameter:
https://<instance name>.service-now.com/nav_to.do?uri=com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=d65394f54ff2520020af09fd0210c759&sys_parm_sdesc='Test Short Desc'
(Add additional parameter in business rule for short description like sys_parm_sdesc='Test Short Desc')
Now that you've passed it you have to use an onload client script on the catalog item itself to consume that parameter and most likely set a value with it like this:
- function onLoad() {
- //Use the 'getParameterValue' function below to get the parameter values from the URL
- var desc = getParameterValue('sys_parm_sdesc');
- if (desc) {
- g_form.setValue('cat_variable', desc);
- }
- }
- function getParameterValue(name) {
- var url = document.URL.parseQuery();
- if (url[name]) {
- return decodeURI(url[name]);
- } else {
- return;
- }
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2017 06:49 PM
yes mate but i dont want to pass the short description to catalog item, i want to pass it to the request form (sc_request). Do you know how description from call gets passed into special instrucions in request?? well i want to do exactly the same but copying short description from call into short description on request.....i have been working on this from a month but still stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2017 08:16 PM
ahh ok. Did you look at Link back to the call that generated it business rule on Request table. you have to tweak the code in that rule. please let me know if you need help on that. add short description to comments variable in CallTypeChanged to Request business rule separated by delimiter and parse it below business rule on Request table
Link back to the call that generated it :
var full_text = current.special_instructions;
var call_id = full_text.substring(13,45); //Extract the call_id
var real_desc = full_text.substring(46,full_text.length); //Extract the actual message
current.special_instructions = real_desc;
var cal = new GlideRecord("new_call");
cal.get(call_id);
cal.transferred_to = current.sys_id;
cal.update();
// update taks work notes
var callerName = cal.caller.name;
var taskType = cal.call_type.getDisplayValue();
var currentLink = "[code]<a href='" + cal.getLink() + "'>" + cal.number + "</a>[/code]";
var journalEntry = gs.getMessage("This {0} was raised on behalf of {1} from {2}", [taskType, callerName, currentLink]);
current.work_notes = journalEntry;
if (GlidePluginManager.isRegistered('com.glide.domain'))
current.sys_domain = getDomain();
var call_url = 'new_call.do?sys_id=' + call_id;
var requ_url = 'sc_request.do?sys_id=' + current.sys_id;
gs.addInfoMessage("<a href='"+call_url+"'>"+cal.number+"</a>"+gs.getMessage(" transferred to ")+": <a href='" +requ_url+ "'>"+current.number+"</a>");
function getDomain(){
// only set the domain if the requested_for has a domain that is not global
if (JSUtil.notNil(current.requested_for) && JSUtil.notNil(current.requested_for.sys_domain) && current.requested_for.sys_domain.getDisplayValue() != 'global')
return current.requested_for.sys_domain;
else
return getDefaultDomain();
}
Thanks,
Sai
Hit Like or Helpful or make it as Correct answer if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2017 08:46 PM
oh yes mate can you give me a hand please. if i add short description in comments variables it will go to special instructions on the request form. and whats all that code above? do i need it? beacuse i cant see the short description in there.. i didnt understand this "separated by delimiter and parse it below business rule on Request table"..thanks dude