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

nishailame
ServiceNow Employee
ServiceNow Employee

Can you try changing table to some OOB table like incident and run the same workflow? I just tried to print current.sys_id and it printed correctly.




Thanks.


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


also HR related tables have some funky restrictions..specially if it is scopped one(istanbul+). make sure user has HR related roles. atlease hr core basic role



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


venkatiyer1
Giga Guru

Hi Kurt,



Whether it be global scope or our custom scope current is part of the scope. For e.g. whenever we create a custom application in that new scope current is a property of that scope. So in your case current should be having the gliderecord object and current.sys_id the sys id value. If that is not coming through check the properties of Workflow and if you still dont get it I believe it needs a deeper look from a HI professional.



I have verified that current gives the glideRecord Object in a custom app.


kurtbell1
Giga Expert

Just to close the thread on this - it had something to do with the workflow.   I rebuilt a scaled-down version of it and the "current" pass worked out just fine. The original workflow has a lot of branches and joins and I suspect this had something to do with it.   I'm just going to try and find a way to make the workflow work how we want it without all of that. Thanks everyone for your help!