Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Blank current object when passing from Workflow to Script Include

kurtbell1
Giga Expert

I have a script include that uses a GlideRecord object as an input.   The Script Include works as it should when I fetch a record and call it from background scripts.   For example:

var caseRecord = new GlideRecord('table');

caseRecord.get([sys id of a record i choose]);

new   x_dnf_application.class()._method(caseRecord);

The above works perfectly.

When I try and call this script include and pass it the "current" object from a workflow, different story.  

This is the code inside the   "Run Script" activity

new   x_dnf_application.class()._method(current);

I have some gs.info writes in the Script Include and the "current" argument is empty when the workflow is executing it.   How could this be?   If I hard-code a string as the argument from the workflow, the string prints out in log successfully, so its an issue with "current", I just don't know what the issue is.

I've also tried sending current.sys_id to see if there's just a problem passing an object versus a single value.   Still passed an empty value.

What am I missing?

8 REPLIES 8

Rushit Patel2
Tera Guru

is your workflow in same scope as script include?



make sure..script include has accessible to "all application" scope set.



(please mark helpful/like/correct if it helps)


Thanks!   They are in different scopes - but the Script Include is available to all scopes. I know its going into the Script since its printing my gs.log entries, but the current object is just empty.   I also just copied the Script Include over to the same scope as the Workflow and updated the api call, but same result. Any other ideas as to what I could be missing?   I'm open to anything.


nishailame
ServiceNow Employee
ServiceNow Employee

Did you try printing the current.sys_id in run script activity?


Which table your workflow is on?





 


Thanks.


PS: Hit like, Helpful, Correct, if it answers your question.


Yes - I put gs.info("Printing current Workflow Sys ID: " + current.sys_id); in the workflow step itself and this is what prints out in the log:



find_real_file.png



The table is a custom table that extends sn_hr_core_case



I might just enter a ticket in Hi unless you (or anyone!) has other ideas?