Requested for not populating correctly on Request and RITM while submitting the service request from cart.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2020 01:59 AM
Hi All,
I have field "requested_for" on catalog item while creating request separately the "requested_for" field on Request and RITM is populating correctly but if I order two items from the "cart" where one has "requested_for" filled and other didnot have "requested_for" filled then both Item takes the "requested_for" field from the catalog which has "requested_for" filed, *Note: if "requested_for" is not filled in a service request then it should take the user who has created the request.
please find the below attachment:
1."requested_for" field in catalog item
2. two item in cart, "one having (Request one behalf of is-- Yes) while other has (Request one behalf of is-- NO)".
3. Business rule which I am using to populate the "requested_for"
*Ideally one "requested_for" should contain value of opened by, while other "requested_for" should contain "requested_for" value from service catalog.
Please help me solve this.
Thanks Shivam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2020 05:43 AM
Hi Shivam,
I could see your BR is on sc_req_item table & you are not updating the requested_for
after line number 3 use this
I assume same variable name i.e. requested_for is present on both the catalog items present in your cart
request.update();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2020 02:30 AM
Hi Ankur,
Thanks for the response, I have added "request.update();" after 3rd line but yet two RITM which I have ordered from the cart at the same time having different "requested for" is taking the same "requested for",
I have observed that on RITM (variable) "requested for" get the reference of Request (variable) "requested for" and when I order the item from the cart, then my business rule sets the "requested for" variable on Request form using one of the RITM. But I need this Business rule, as when I order the item seperately - it runs very well there, but when it comes to order from cart its not work accordingly. Please find the screenshot for the same:
Thanks,
Shivam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2020 03:17 AM
Hi Shivam,
for both the RITMs is the variable name same i.e. requested_for?
if both the catalog items are having different variable name then use this
var request = current.request.getRefRecord();
if(current.cat_item.name == 'Catalog Item 1'){
request.requested_for = current.variables.requested_for; // use variable from this catalog item
}
if(current.cat_item.name == 'Catalog Item 2'){
request.requested_for = current.variables.requested_for; // use variable from this catalog item
}
request.update();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2020 04:06 AM
Hi Ankur,
for most of the RITM variable "Requested_for" is the same.
Thanks,
Shivam.