Populated Requested for from call module

kun1
Tera Expert
 

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.

 

 

1 ACCEPTED SOLUTION

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);
}

View solution in original post

16 REPLIES 16

Tushar Sharma2
Kilo Guru

Hello Kun,

This is the OTTB behavior as you are requesting on behalf of other caller. You need to set the value of field "requested for" from caller field while redirecting. Requested by will be auto-populated OTTB with logged in user name. 

Mark Correct if it solved your issue.
Regards,
Tushar Sharma
www.dxsherpa.com

I am doing like this 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;


}


}

Could you please define  var reqFor = current.caller; under the function getCart(); and let me know if it works.

Mark Correct if it solved your issue.
Regards,
Tushar Sharma
www.dxsherpa.com

NOPE not wokring