Setting "Requested for" field when submitting a request

Mark Van Loock
Tera Guru

Hi,

 

I thought I would follow this article to set the "Requested for" field.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0529490

 

It seems simple enough - run a client script that calls a "Script Include", but I am getting "Javascript error".

 

Here's the script from the article. Can anyone see what could be wrong here?

 

var CartRequestFunction = Class.create();
CartRequestFunction.prototype = Object.extendsObject(AbstractAjaxProcessor, {
cartRequestFunction: function () {
var requestedFor = this.getParameter('sysparm_requestedFor');
var cart = new GlideRecord('sc_cart');
var userid = this.getParameter('sysparm_currentUser');
cart.addQuery('user', userid);
cart.query();
if(cart.next()){
// Update Requested for in the cart
if (cart.requested_for != requestedFor) {
cart.requested_for = requestedFor;
cart.update();
}
}
}
});

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

This knowledge article predates the introduction of the 'Requested For' variable set which allows for a seperation between Opened By and Requested For. 

 

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/service-catalog-man...

View solution in original post

2 REPLIES 2

Kieran Anson
Kilo Patron

This knowledge article predates the introduction of the 'Requested For' variable set which allows for a seperation between Opened By and Requested For. 

 

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/service-catalog-man...

Mark Van Loock
Tera Guru

Fantastic!! Thank you Kieran. That was so easy - instead of a "Reference" variable, changing that to "Requested for" has done everything I needed it to.