Create RITM taking Information from 3rd Party

Prathamesh Chav
Tera Contributor

Hi Team,

 

My requirement is to Create RITM taking Information from 3rd Party.

Here user will submit one form related Onboarding, then request will get submitted in that application then i want to pull that data daily basis and create RITM in ServiceNow with same details filled in variables of that RITM because that form is also available here.

 

Do I need to use here scripted rest message? if yes what should be the approach?

or Should I use get Rest Message to get the info and simply use that script in schedule script and run that script every 3o min and in script use that data and create RITM ?

Is there any another approach I should be using?

 

Thanks ,

BR

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Prathamesh Chav 

yes you can use scripted REST API and use Cart API or CartJS and it will set RITM variables

Once RITM is created the associated workflow or flow will get triggered

try {

    var cartId = GlideGuid.generate(null);
    var cart = new Cart(cartId);
    //add your requested item to the cart by sys_id of the catalog item
    var item = cart.addItem('0336c34407d0d010540bf2508c1ed096', 1);

    //fill in the variables on the request item form
    cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
    cart.setVariable(item, "multiple_choice", "Phoenix");
    var rc = cart.placeOrder();
    gs.info(rc.number);

} catch (ex) {
    gs.info(ex);
}

Another way

try {
    var cart = new sn_sc.CartJS();
    var item = {
        'sysparm_id': '0336c34407d0d010540bf2508c1ed096',
        'sysparm_quantity': '1',
        'variables': {
            'user': '7282abf03710200044e0bfc8bcbe5d03',
            'asset': '00a96c0d3790200044e0bfc8bcbe5dc3',
            'multiple_choice': 'Phoenix',
        }
    };
    var cartDetails = cart.addToCart(item);
    var checkoutInfo = cart.checkoutCart();
    gs.info('Order details' + JSON.stringify(checkoutInfo));
} catch (ex) {
    gs.info('Exception' + ex);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

6 REPLIES 6

Adrian Ubeda
Mega Sage
Mega Sage

Hello Prathamesh, 
You can create your own scripted REST API but i'll recommend you to use the CartJS API OOTB and also the service catalog API.

With these two you can create your request without going deeper into variables tables which can be quite complex in terms of coding, and apart form that does not scale too much.

You can create a scripted rest API just only for intaking the request and then process using this libraries for creating the objects and RITM as needed and reply with a desired message. 
Here are some link: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/inbound-rest/concept/c_...

https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_referenc...

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Hi @Vutikonda Vinay @Adrian Ubeda ,

 

I have visited the above URL, I tried with cart API but its not creating any RITM or request could you please  suggest me any syntax with usecase.

 

Thanks

Vutikonda Vinay
Tera Contributor

Hello, 

 

You would be use the Flow Designer(no code). Here is the approach, First create REST Action to pull the data make sure your connection is success by using Test Rest Step, then create a Subflow to call the rest step and with that data create a record in certain table then create flow with 30 min frequency. 

 

Thank you!

Hi @Vutikonda Vinay ,

 

Got your Point, I want to know about the last part where we are creating record which is RITM, I am able to create but not able to populate Variables with RITM.

please guide me in that

 

Thanks