- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 01:20 AM
Hi Team,
We have a new call in which we have caller field (back end name :caller).So, when we set the call type as request it redirect it to a sc_cat_item view.
NEW CALL:-
After submitting the for, the view is like this:-
So here is the issue is In the caller form i set the caller as A (log in in service now from B), and when it redirect to catalog item view, In the requested for, it set the vale B(Log-in from B). So, please help me here.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 01:48 AM
Just try these lines in your onLoad client script and see if it works
function onLoad(){
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var user = decodeURI(gUrl.getParam("sysparm_requested_for"));
alert(user);
g_form.setValue('reqFor', user);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 01:29 AM
Hello,
You will need to copy the Caller from new call form and add it on your catalog item form using an Onload client script.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 01:33 AM
Please help me with the script part.
I wrote one BR and one catalog client script but no luck 😞
BR:-
Condition:- current.call_type.changesTo('sc_request') && current.transferred_to.nil()
Code:-
var reqFor = current.caller;
gs.log(current.caller + "caller kk");
var contactType = current.contact_type;
var location = current.caller.location;
var reqItem = current.request_item;
var comments = "NEW_CALL_REF:" + current.sys_id + " " + current.description;
getCart();
var url = "com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=" + reqItem
+ "&sysparm_requested_for=" + GlideStringUtil.urlEncode(reqFor)
+ "&sysparm_location=" + GlideStringUtil.urlEncode(location)
+ "&sysparm_special_instructions=" + GlideStringUtil.urlEncode(comments)
+ "&sysparm_stack=" + current.getLink()
+ "&sysparm_contact_type=" + contactType + "&sysparm_caller=" +current.caller;
action.setRedirectURL(url);
function getCart() {
var cart = new GlideRecord('sc_cart');
var userid = gs.getUserID();
cart.addQuery('user', userid);
cart.query();
if (cart.next()) {
// We already have a cart so override the requested for value and empty it
cart.requested_for = reqFor;
cart.contact_type = contactType;
cart.special_instructions = comments;
cart.delivery_address = getDeliveryAddress();
cart.update();
var cartItems = new GlideRecord('sc_cart_item');
cartItems.addQuery('cart', cart.sys_id);
cartItems.deleteMultiple();
} else {
cart.initialize();
cart.user = userid;
cart.requested_for = reqFor;
cart.contact_type = contactType;
cart.special_instructions = comments;
cart.delivery_address = getDeliveryAddress();
cart.insert();
}
return cart;
}
function getDeliveryAddress() {
var gr = new GlideRecord('cmn_location');
if (!gr.get(location))
return '';
var text = '';
if (!gr.street.nil())
text = gr.street + '\n';
if (!gr.city.nil() && !gr.state.nil() && !gr.zip.nil())
text += gr.city + ", " + gr.state + ", " + gr.zip;
return text;
}
Catalog client script:-
Type: Onload
Applies to:- catalog item
function onLoad() {
//Use the 'getParameterValue' function below to get the parameter values from the URL
var user = getParameterValue('sysparm_user');
var ds = getParameterValue('sysparm_description');
var sd = getParameterValue('sysparm_short_description');
if (user) {
g_form.setValue('reqFor', user);
}
if (ds) {
g_form.setValue('additional_comments', ds);
}
if (sd) {
g_form.setValue('short_description', sd);
}
}
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
12-28-2018 01:35 AM
Please change these lines in your script and it should work
var user = getParameterValue('sysparm_requested_for');
var ds = getParameterValue('sysparm_description');
var sd = getParameterValue('sysparm_short_description');
if (user) {
g_form.setValue('reqFor', user);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 01:37 AM
function onLoad() {
//Use the 'getParameterValue' function below to get the parameter values from the URL
var user = getParameterValue('sysparm_requested_for');
var ds = getParameterValue('sysparm_description');
var sd = getParameterValue('sysparm_short_description');
if (user) {
g_form.setValue('reqFor', user);
}
if (ds) {
g_form.setValue('additional_comments', ds);
}
if (sd) {
g_form.setValue('short_description', sd);
}
}
function getParameterValue(name) {
var url = document.URL.parseQuery();
if (url[name]) {
return decodeURI(url[name]);
} else {
return;
}
}
not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 01:41 AM
Are you using London? Can you add an alert and see what it returns?
var user = getParameterValue('sysparm_requested_for');
alert(user);