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

Shivam21
Tera Contributor

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 itemfind_real_file.png

2. two item in cart, "one having (Request one behalf of is-- Yes) while other has (Request one behalf of is-- NO)".

find_real_file.png

3. Business rule which I am using to populate the "requested_for"

find_real_file.png

 

*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.

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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:

find_real_file.png

Thanks,

Shivam.

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

for most of the RITM variable "Requested_for" is the same.

Thanks,

Shivam.