Integration between SOAR and ServiceNow

Thereza Van der
Tera Contributor

Good afternoon everyone 🙂

 

Please assist me in getting the following done, I am on Washington release of SNow:

 

We need to integrate with SOAR. They want to automatically create a service request in ServiceNow and in that request they want a text box in which they can copy all the necessary information in.

 

I created a service account. I am just not sure what extra roles are needed.

I created a catalog item for them (SOAR).

I created a REST API with two records (create request and retrieve request).

 

The request gets created successfully (REQ, RITM and SCTASK) but nothing is populated in the task. I want to use the description field as their string field so they can populate all the necessary information in there.

 

Or if there is a better way to do this, I would appreciate any assistance. I attach screenshots of everything I did.

 

Thanks for your assistance and for your patience with me every time 🙂

 

 

Regards

Thereza

1 ACCEPTED SOLUTION

Hi @Thereza Van der 

Ok, will do the integration step by step. As per my understanding you need 'additional info' populate on RITM ticket.

- Have you created variable (field) on your catalog item? if not create one variable with type string.

- Add following script in your 'CreateRequest' API and do the needful changes, I have added the comments for your understanding.

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
    // Get the request body
    var requestBody = request.body.data;
    var additionalInfo = requestBody.additional_info || ''; // Retrieve additional information from request body

    // Create a new Service Catalog request
    var requestGR = new GlideRecord('sc_request');
    requestGR.initialize();
    requestGR.requested_for = gs.getUserID(); // Request for the current user
    requestGR.short_description = 'Automated Service Request'; // Short description for the request
    var requestSysID = requestGR.insert();

    if (!requestSysID) {
        response.setStatus(500);
        response.setBody({error: 'Failed to create service request'});
        return;
    }

    // Create a request item (sc_req_item)
    var itemGR = new GlideRecord('sc_req_item');
    itemGR.initialize();
    itemGR.request = requestSysID;
    itemGR.cat_item = 'sys_id_of_catalog_item'; // Replace with the sys_id of the catalog item you want to use
    itemGR.short_description = 'Automated Service Request Item';
    itemGR.insert();

    // Create a variable entry for additional information
    var varGR = new GlideRecord('sc_item_option');
    varGR.initialize();
    varGR.request_item = itemGR.sys_id;
    varGR.item_option_new = 'sys_id_of_additional_info_variable'; // Replace with the sys_id of the variable for additional info
    varGR.value = additionalInfo;
    varGR.insert();

    // Return the response
    response.setStatus(201);
    response.setBody({
        message: 'Service request created successfully',
        request_sys_id: requestSysID
    });

})(request, response);

 

Test this by creating few service request and validate text box in service requests capture and store correct information.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

THANK YOU

rajesh   

 

View solution in original post

7 REPLIES 7

Rajesh Chopade1
Mega Sage

Hi @Thereza Van der 

I have gone through shared images and I will suggest you following points:

1) Roles Needed:

  • rest_service: Allows the service account to interact with ServiceNow via REST API.
  • catalog: Grants access to the Service Catalog.

2) Populate the Description Field via REST API:

  • In your REST API for creating the request, ensure that the payload includes the description. For example:

 

{

    "requested_for": "user_id",

    "variables": {

        "description": "Your text content here"

    }

}

 

  • Ensure that the catalog item's variables include a description field (or a similar text field), which will map to the ServiceNow sc_task or ritm description.

3) Service Catalog Item Configuration:

  • Ensure the Catalog Item has a Variable for Description:
    • Create a variable in the catalog item for capturing the information (e.g., a large text box for description).
  • Map the Variable to Task Fields:
    • Use a Catalog Task Workflow or Script to map the variable to the description field in the resulting tasks (RITM, SCTASK).

4) Adjust Workflow or Business Rule:

  • If the information is not automatically populating in the tasks, consider using a workflow or business rule to copy the catalog item’s description into the RITM or SCTASK description fields.

 

current.description = current.variables.description;

 

This script can be placed in a business rule or in the workflow's "Script" activity to copy the text from the catalog item's variable to the task's description field.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer correct and helpful.

THANK YOU

rajesh chopade

Thereza Van der
Tera Contributor

Hi Rajesh

 

I have been battling with this since you gave your answer. I am not a developer, I don't understand the coding and I have never done REST API's before. I am a fairly new administrator but we don't have a developer so I am expected to do everything. I cannot tell you how much videos I have watched, how much articles I've read, how many times I've tried and retried and retried. I cannot get it to work. One of the things I cannot do is:

 

  • Use a Catalog Task Workflow or Script to map the variable to the description field in the resulting tasks (RITM, SCTASK).

I am doing courses in the mean time to skill myself up but this is a request that needs to be done as a matter of urgency so there is no time to wait for me to be upskilled. Can you please explain how to do the bulleted part in my response? I did create a business rule but not sure if what I did is correct. I attach a screenshot so you can see at least I tried.

Hi @Thereza Van der 

Ok, will do the integration step by step. As per my understanding you need 'additional info' populate on RITM ticket.

- Have you created variable (field) on your catalog item? if not create one variable with type string.

- Add following script in your 'CreateRequest' API and do the needful changes, I have added the comments for your understanding.

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
    // Get the request body
    var requestBody = request.body.data;
    var additionalInfo = requestBody.additional_info || ''; // Retrieve additional information from request body

    // Create a new Service Catalog request
    var requestGR = new GlideRecord('sc_request');
    requestGR.initialize();
    requestGR.requested_for = gs.getUserID(); // Request for the current user
    requestGR.short_description = 'Automated Service Request'; // Short description for the request
    var requestSysID = requestGR.insert();

    if (!requestSysID) {
        response.setStatus(500);
        response.setBody({error: 'Failed to create service request'});
        return;
    }

    // Create a request item (sc_req_item)
    var itemGR = new GlideRecord('sc_req_item');
    itemGR.initialize();
    itemGR.request = requestSysID;
    itemGR.cat_item = 'sys_id_of_catalog_item'; // Replace with the sys_id of the catalog item you want to use
    itemGR.short_description = 'Automated Service Request Item';
    itemGR.insert();

    // Create a variable entry for additional information
    var varGR = new GlideRecord('sc_item_option');
    varGR.initialize();
    varGR.request_item = itemGR.sys_id;
    varGR.item_option_new = 'sys_id_of_additional_info_variable'; // Replace with the sys_id of the variable for additional info
    varGR.value = additionalInfo;
    varGR.insert();

    // Return the response
    response.setStatus(201);
    response.setBody({
        message: 'Service request created successfully',
        request_sys_id: requestSysID
    });

})(request, response);

 

Test this by creating few service request and validate text box in service requests capture and store correct information.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

THANK YOU

rajesh   

 

Thereza Van der
Tera Contributor

Rajesh, thank you for all your efforts. I am trying it out now. Just a quick recap of what the end goal is:

 

SOAR and ServiceNow needs to be integrated so that SOAR can automatically create a request in ServiceNow through a catalog item (soar_integration). They also need to be able to populate the 'additional_information' field with information which then needs to be stored again. I am not sure if it is in the RITM or the SCTASK. I was under the impression that it needs to be stored in the task as task gets automatically sent to the 'BST-Database Admin' group. The problem is I don't get the request number back and SOAR needs that to setup on their side.

TherezaVander_0-1723553594219.png

 

So we should do a POST to place a new "order" and also provide the additional_information in the request body, then get a REQ number back.

 

I found documentation that might help on the developer forum but I don't have experience and I get lost.
https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/rest/c_ServiceCatalogAPI#servic...

TherezaVander_1-1723553705216.png

 

The SOAR team says they need the request number

TherezaVander_2-1723553853023.png

From what I've read, I also need PUT if they want to update the record and sen it back?

 

I hope it makes sense?

 

I will try your suggestion now and give feedback, thanks once again 🙂