I have to create inbound action.

niveditakumari
Mega Sage

Hi, 

 

I have to create Inbound Action. 

1) Create an inbound action to accommodate email coming from portal@remota.com to servicenow's mailbox
2) This RITM catalog item name would be Device Unlock Request, short description of the RITM upon creation would be -> Device Unlock Request - <RITM_Creation_Date>
3) REQ short description and description = Device Unlock Request
4) RITM would be assigned to Support Engineering - Tier 1 group
5) Email body would be pasted into RITM description 
[Note: Mostly email body would contain a table which would host two columns, Device Serial and Offboarding date. Table would contain multiple rows i.e. multiple device information altogether in a single email, we aren't creating ticket per device at the moment rather clubbing into RITM as an initial process]
4) Priority would be set as P3 

 

Can you please help me to create Inbound Action to achieve that. 

 

Regards, 

Nivedita 

 

 

4 REPLIES 4

Matthew_13
Mega Sage

Hi Buddy,

 Here’s the simplest and most accurate way to do it that i can come up with.

Create an Inbound Email Action (Type = New) with this condition:

email.from && email.from.toLowerCase() == 'portal@remota.com'

Use this script replace the two sys_ids:

(function runAction(email, action, event) {

    var CAT_ITEM_SYSID = 'DEVICE_UNLOCK_CATITEM_SYSID';
    var TIER1_GROUP_SYSID = 'SUPPORT_ENGINEERING_TIER1_SYSID';

    // Create REQ
    var req = new GlideRecord('sc_request');
    req.initialize();
    req.short_description = 'Device Unlock Request';
    req.description = 'Device Unlock Request';
    var reqId = req.insert();

    // Create RITM
    var ritm = new GlideRecord('sc_req_item');
    ritm.initialize();
    ritm.request = reqId;
    ritm.cat_item = CAT_ITEM_SYSID;
    ritm.short_description = 'Device Unlock Request - ' + gs.nowDate();
    ritm.description = email.body_text || GlideStringUtil.stripHTML(email.body_html);
    ritm.assignment_group = TIER1_GROUP_SYSID;
    ritm.priority = 3; // P3
    ritm.insert();

    action.setAbortAction(true);

})(email, action, event);

This will:

  • Create one REQ + one RITM per email

  • Set the correct short descriptions

  • Copy the full email body (including tables as text) into the RITM

  • Assign to Support Engineering – Tier 1

  • Set Priority = P3

If you later want to parse the device table into structured data, that can be added on top of this.

 

@niveditakumari - Please mark Accepted Solution and Thumbs Up if you find Helpful 🙂

MJG

yashkamde
Tera Guru

Hello @niveditakumari ,

You can create a flow for that,

select the trigger condition as inbound email and type as SMTP -> then create a request for linking the ritm into that
Screenshot 2026-01-17 152700.png

then create a ritm in which add req -> select data pill upper created REQ
Screenshot 2026-01-17 152717.pngThis is the automated inbound action..
If my response helped mark as helpgul and accept as solution.

vaishali231
Tera Guru

hey @niveditakumari 

here simple script :

condition

email.from && email.from.toLowerCase() == 'portal@remota.com'

Script :

(function runAction(email, action, event) {

    // Get catalog item sys_id
    var catItemGR = new GlideRecord('sc_cat_item');
    catItemGR.addQuery('name', 'Device Unlock Request');
    catItemGR.query();

    if (!catItemGR.next()) {
        gs.log('Device Unlock Request catalog item not found');
        return;
    }

    // Create RITM
    var ritm = new GlideRecord('sc_req_item');
    ritm.initialize();

    ritm.cat_item = catItemGR.sys_id;
    ritm.short_description = 'Device Unlock Request - ' + gs.nowDate();
    ritm.description = email.body_text;

    // Assignment Group
    var groupGR = new GlideRecord('sys_user_group');
    groupGR.addQuery('name', 'Support Engineering - Tier 1');
    groupGR.query();

    if (groupGR.next()) {
        ritm.assignment_group = groupGR.sys_id;
    }

    // Priority P3
    ritm.priority = 3;

    ritm.insert();

})(email, action, event);

*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.

Regards
Vaishali Singh

jimjqliao
Tera Contributor

To achieve this in ServiceNow, you will use an Inbound Email Action with a script utilizing the Cart API. This API programmatically simulates ordering a catalog item, ensuring that the Request (REQ) and Requested Item (RITM) are created and linked correctly. 

Step 1: Configuration Details
Navigate to System Policy > Inbound Email Actions and create a new record with the following settings: 
  • Name: Create Device Unlock RITM
  • Target Table: Requested Item [sc_req_item]
  • Type: New
  • Condition: email.from == 'portal@remota.com' (Ensures only emails from this address trigger the action). 
Step 2: The Script
Paste the following script into the Actions tab. You must replace 'SYS_ID_OF_CATALOG_ITEM' and 'SYS_ID_OF_SUPPORT_ENGINEERING_GROUP' with the actual Sys IDs from your instance. 
(function runAction(current, event, email, logger, classifier) {
    // 1. Initialize Cart API to simulate order
    var cartId = GlideGuid.generate(null);
    var cart = new Cart(cartId);
    var item = cart.addItem('SYS_ID_OF_CATALOG_ITEM'); // Replace with 'Device Unlock Request' Sys ID

    // 2. Place the order
    var rc = cart.placeOrder();
    var requestId = rc.sys_id;

    // 3. Update the Request (REQ) record
    var reqGR = new GlideRecord('sc_request');
    if (reqGR.get(requestId)) {
        reqGR.short_description = "Device Unlock Request";
        reqGR.description = "Device Unlock Request";
        reqGR.update();
    }

    // 4. Update the Requested Item (RITM) record
    var ritmGR = new GlideRecord('sc_req_item');
    ritmGR.addQuery('request', requestId);
    ritmGR.query();
    if (ritmGR.next()) {
        // Date formatting for Short Description
        var gdt = new GlideDateTime();
        var creationDate = gdt.getLocalDate().getByFormat("yyyy-MM-dd");

        ritmGR.short_description = "Device Unlock Request - " + creationDate;
        ritmGR.description = email.body_text; // Paste email body (table data) into description        ritmGR.priority = 3; // Priority P3        ritmGR.assignment_group = 'SYS_ID_OF_SUPPORT_ENGINEERING_GROUP'; // Replace with Support Engineering - Tier 1 Sys ID        ritmGR.update();
        
        // Associate the incoming email with the newly created RITM        sys_email.instance = ritmGR.sys_id;
        sys_email.target_table = "sc_req_item";
    }

    event.state = "stop_processing"; // Prevent other inbound actions from running})(current, event, email, logger, classifier);