- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2018 07:09 AM
Hello all
I would like that when we click on the link "Creation of account"= >a request is created by applying the "catalog item" which is called "" Creation of account "
The sysId of this "catalog item" is "5ab22dd36fe39900a3e267712e3ee414"
I created this script
The request is creating well but not the RITM (request_item)!
Thank your four your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2018 03:18 AM
Hi David,
I try this script and it works well:
createServiceRequest();
function createServiceRequest() {
var cart = new Cart();
var item = cart.addItem('5ab22dd36fe39900a3e267712e3ee414');
cart.setVariable(item, 'short_description', "Request to create an account");
cart.setVariable (item,'User',current.sys_id);
cart.setVariable (item,'Location',current.location);
cart.setVariable (item,'login',current.user_name);
var cartGR = cart.getCart();
cartGR.requested_for = current.sys_id;
cartGR.update();
var newSerReq = cart.placeOrder();
newSerReq.update();
var disMessage = 'created request: ' + newSerReq.number;
gs.addInfoMessage(disMessage);
action.setRedirectURL(newSerReq);
action.setReturnURL(current);
}
function getRITM(serReq) {
var ritm = '';
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request',serReq);
grRITM.query();
if(grRITM.next()) {
ritm = grRITM.sys_id;
}
return ritm;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2018 07:16 AM
Hi Mustapha,
You haven't created an RITM record so there is nothing there to dot-walk to. You'll need to add another glide record to the sc_req_item table and create a record there and link it back to your new request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2018 07:19 AM
Also, you should use initialize() when creating new records, it creates an empty record that can then be populated with info.
var demande = new GlideRecord('sc_request');
demande.initialize();
demande.short_description = .....etc etc etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2018 08:31 AM
thank you David for your reply.
But how to link it back this RITM to the created request.
I add the following script but the ritm does not appear in the "requested items":
var grRITM = new GlideRecord('sc_req_item');
grRITM.initialize();
grRITM.cat_item= "5ab22dd36fe39900a3e267712e3ee414";
grRITM.request = demande;
grRITM.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 02:05 AM
Hi Mustapha,
Change it as below, demande is just a glide record object it will return undefined.
grRITM.request = demande.sys_id;