Shopping cart - Requested for
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2015 06:28 AM
When a user adds an item to the cart and changes the Requested for field, the Contact information (address) does not update.
Also, the Requested for defaults to the last person the user selected. As you can see Chris Overpeck is logged in and had previously changed the Requested for to Brenda Hoyt and the Contact information (address) did not update. I had him go back in and Brenda Hoyt is still selected as the Requested for. Ideally Requested for would default to the person who is logged in AND if it were changed the Contact information would update to reflect the address of the user that has been selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2015 11:58 AM
Can you share some of the code on how you did this?
I assume you hid the requested for and delivery address on the shopping cart. Then on submit pushed the values of the Requested for and Address variables to the sc_request and sc_req_item forms. This way you are not customizing the shopping cart and breaking any upgrades.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2015 12:37 PM
I didn't touch the Shopping Cart UI Page, but if requested_for and delivery_address are currently visible, just comment out the portion of code that display both fields (yes, you will loose upgrades of the UI Page. You'll have to update it manually moving forward).
What I was referring is to have a requester_for variable within the catalog item, you write an OnLoad script to get the current logged-in user to auto-populate the variable; allow the end user to change the value of the requester_for. Once the user clicks submit button then you write a business rule at insert in sc_req_item table to copy the requester_for variable value into the requester field of the sc_request table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 09:48 AM
I got the location and the address populated on the Cat item be am having issues with the BR on insert on sc_req_item table
reqfor is the variable
var grRITM = new GlideRecord('sc_request');
grRITM.addQuery('sys_id', current.request.sys_id.toString());
grRITM.query();
while (grRITM.next()) {
grRITM.requested_for = current.variables.ReqFor;
grRITM.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 10:57 AM
Got the BR working:
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request', current.sys_id.toString());
grRITM.query();
while (grRITM.next()) {
current.requested_for = grRITM.variables.ReqFor;
grRITM.update();
}
What if someone is creating a request with the same 2 cat items for 2 different people?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 01:30 PM
that's a different scenario.
Say a manager Rob, wants to request computers for his subordinates Mike and Susan. The catalog item should be a single form to request a single computer, hence the variable within the catalog item should be addressed for Mike and Susan.
Rob, will have to order two computers using the same catalog item twice, one for Mike and another for Susan, both will have to be added to the shopping cart. At the end once the cart is submitted there should be one request and two requested items.
For this scenario you will have to create a custom field in the sc_req_item table called "Requested For" and copy the value from the catalog item variable. By default ServiceNow enters the name of the current logged-in user in the "Requested for" field in sc_request table, this is because the cart table has this field auto-populated when adding items to the cart.
Following this approach your request (sc_request) will have the name of Rob, the manager, in the "Requested for" OOB field. With the business rule (on-before) for sc_req_item, you'll be copying the variable value into "Requested For" field from the RITM itself ending with two RITMs, one for Mike and another for Susan.