How to call script include in scripted rest api

rambabu1
Giga Expert

Hi,

Is there a way to call script include in scripted rest api 

5 REPLIES 5

Allen Andreas
Administrator
Administrator

Hello,

You can utilize any server side API in your scripted rest API.

Examples: https://community.servicenow.com/community?id=community_question&sys_id=ee030fa1dbd8dbc01dcaf3231f96...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hello,

I see you're only replying below, but I'll respond up here to keep my chain in tact.

If you're seeing [object, object] that you're getting back from your script include, then that means you're passing an object...instead of string. You'd need to convert your obj to string in your script include and then pass the string value.

This is a separate question to your question above, as your question was how to use a script include in scripted REST API, which I've answered above.

I hope the above answers your question. Thanks! šŸ™‚

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Chandu Telu
Tera Guru
Tera Guru
Hi Rambabu, It's similar way how call the script include form server side Ex: Script include name : abc and function name is test new abc().test(parameters)

i am getting like [object object] using below script. how can i resolve this

 
var test1 = new scriptinclude();
var test= test1.stringify();

// Create New Form

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);


var item = cart.addItem('item sys_id', 1);


cart.setVariable(item, "user", test);