- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 12:09 AM
Hi
I have a requirement, RITM and Catalog task will be created when an email sent to SNow. I tried through Inbound Action. Ritm is creating but Catalog task is not creating.
Requested for is not populating in RITM as it should be taken from email body. Any one can help me please
Here is my Inbound action Script:
RITM ---
var REQ = new GlideRecord('sc_request');
REQ.requested_for = email.body.userid;
current.stage = 'fulfillment';
current.approval='approved';
current.state = 'New';
current.description = email.body_html;
current.cat_item.setDisplayValue('User update');
current.insert();
event.state = "stop_processing";
----
Catalog Task ---
var REQ = new GlideRecord('sc_request');
REQ.requested_for = email.body.userid;
current.location = email.body.location;
current.description = email.body_html;
current.state = 'Assigned';
current.insert();
----
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 12:36 AM - edited ‎01-25-2023 12:39 AM
Hi,
Do you have a catalog in the system that needs to be submitted by inbound action?
If yes, please use cart API to submit the catalog. If there is a flow/workflow attached to it you can easily create catalog inside flow/wf.
Below is a sample script.
var cartId = GlideGuid.generate(null);
var catalogItemID = "526c35c71b8005508a6c9821b24bcb36";
var cart = new Cart(cartId);
var item = cart.addItem(catalogItemID);
cart.setVariable(item, "requestedby",gs.getUserID());//name of catalog item variable
cart.setVariable(item, "requestedfor",gs.getUserID());///name of catalog item variable
cart.placeOrder();
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 12:55 AM - edited ‎01-25-2023 12:57 AM
Hi,
In servicenow, you should create the task using workflow/flow.
Technically it possible to create catalog task using script as it is just a record of table but we should not be creating the task in this way.
Anyways Catalog management in servicenow having three table involved-
REQ (Always created if a catalog is raised)
RITM (Always created)
SCTASK (Optional)
First you should raise a catalog using cart API, after that you can create catalog task using script.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 01:53 AM
Please share you ritm record screenshot as well.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 02:15 AM
Hi,
Use below code (Be aware this all is ok for practice purpose but in projects you should do in a way that servicenow recommend)
var REQ = new GlideRecord('sc_request');
var usr=new GlideRecord('sys_user');
usr.get('user_name',email.body.userid)
REQ.requested_for = usr.sys_id;
REQ.insert();
current.request=REQ.sys_id;
current.stage = 'fulfillment';
current.approval='approved';
current.state = 'New';
current.description = email.body_html;
current.cat_item.setDisplayValue('User update');
current.insert();
event.state = "stop_processing";
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 12:36 AM - edited ‎01-25-2023 12:39 AM
Hi,
Do you have a catalog in the system that needs to be submitted by inbound action?
If yes, please use cart API to submit the catalog. If there is a flow/workflow attached to it you can easily create catalog inside flow/wf.
Below is a sample script.
var cartId = GlideGuid.generate(null);
var catalogItemID = "526c35c71b8005508a6c9821b24bcb36";
var cart = new Cart(cartId);
var item = cart.addItem(catalogItemID);
cart.setVariable(item, "requestedby",gs.getUserID());//name of catalog item variable
cart.setVariable(item, "requestedfor",gs.getUserID());///name of catalog item variable
cart.placeOrder();
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 12:51 AM
I need to create a sc_task through inbound action.
TASK:
Requested for: Depends on UserID (email body)
Location: Taken from the UserID
Short description: email subject
Description: Body email
State: Assigned
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 12:55 AM - edited ‎01-25-2023 12:57 AM
Hi,
In servicenow, you should create the task using workflow/flow.
Technically it possible to create catalog task using script as it is just a record of table but we should not be creating the task in this way.
Anyways Catalog management in servicenow having three table involved-
REQ (Always created if a catalog is raised)
RITM (Always created)
SCTASK (Optional)
First you should raise a catalog using cart API, after that you can create catalog task using script.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2023 01:44 AM
Thanks for your information
I have one last question, Ritm is creating but requested for is empty in Ritm
It should be autofilled through email body