Need to pass ritm field values to work flow which is calling from the script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2020 09:31 AM
I am creating a request from inbound action. And I am creating corresponding ritm using business rule. In the business rule after creating the ritm, I am calling a workflow which is on requested item table. There is only one run script activity in the workflow. In that run script activity, I want the ritm number and requested for values in a scratchpad variable. Workflow is triggering but the related ritm number and requested for is not coming . I checked with log messages also. Can someone help me here. It's a bit urgent
For my code, please see this link
https://community.servicenow.com/community?id=community_question&sys_id=b1745ecd1b946410305fea89bd4bcb41
Regards,
Indup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2020 07:48 PM
Yeah, right!
That's the correct way to do it.
But for this, you need to have a catalog item (without any variables/scripts as required by you), item should have name and workflow that you want to attach. As, this cart API automates everything, request/RITM will be created and workflow will be automatically attached.
Catalog Item (fill it acc to your requirement)
Script in Inbound Action:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem(<sysid of catalog item>);
var rc = cart.placeOrder();
gs.addInfoMessage("Request Created " + rc.number);
var popFields = new GlideRecord("sc_request");
popFields.addQuery("number",rc.number);
popFields.query();
if(popFields.next())
{
popFields.u_title = email.body.title; // fields that you want to populate
.
.
.
popFields.update();
}
Workflow (Run script)
current.number gives RITM Number
current.request.requested_for gives Requested for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2020 09:19 PM
Hello Shivani,
Thanks for the code. But once i send mail to snow, request is not getting created. When i check the email received, it is showing like this,
Body Text Contains1 is the name of my inbound action. And i have a doubt, in your code why did u glide record request table when inbound action is already present on Request?
Regards,
Indup

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2020 09:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2020 09:49 PM
Oh, didn't notice that then keep it this way
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem(<sysid of catalog item>);
var rc = cart.placeOrder();
gs.addInfoMessage("Request Created " + rc.number);
rc.u_title = email.body.title; // fields that you want to populate
.
.
.
rc.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2020 10:20 PM