Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Can you define a scratchpad variable as an array

johannes5
Giga Expert

Hi ServiceNow Community Developers,

Is there a way to define a scratchpad variable as an array? Basically can you declare a scratchpad variable as an array just like you would with an other field in a script in ServiceNow? Please advise.

Thanks,

Johannes

1 ACCEPTED SOLUTION

elemonnier
Tera Expert

I tested this out in a workflow and it worked fine. So yes, you can!


var test_array = [];


test_array.push('test1');


test_array.push('test2');


workflow.scratchpad.new_array = test_array;


View solution in original post

3 REPLIES 3

Uncle Rob
Kilo Patron

Don't see why not.   You could always do a test run where you set a scratchpad to an array, then gs.log it in the next activity (assuming you're not working in a scoped app)


elemonnier
Tera Expert

I tested this out in a workflow and it worked fine. So yes, you can!


var test_array = [];


test_array.push('test1');


test_array.push('test2');


workflow.scratchpad.new_array = test_array;


Thanks Guys for your responses