current and current.variables?

acg
Kilo Contributor

I'm somewhat new to using scripting on SN. I was playing with workflow scripting and I just can't figure out what is the difference and the proper usage between current.variables.variablename or just using current.variablename? Within the same script, in some cases, both work, and in other cases, only current.variablename work ? search the internet and can't seem to find an answer. Thanks in advance for any clarifications.

1 ACCEPTED SOLUTION

venkatiyer1
Giga Guru

Your current is the table on which the workflow is currently running.


current.variables.variablename is the right way to fetch all the variables that were declared in the catalog item and now


a part of the requested item. So generally this gets picked up from the Variable ownership table in correlation to the requested item.



current.variablename would also sometimes work if you had the same variable or in this case column name defined in the current table.



So if were to take the flow of catalog item to requested item, anything in the catalog item that you would like to refer


you would use the current.variables.variablename and anything in requested item table by itself you would use current.variablename


View solution in original post

9 REPLIES 9

venkatiyer1
Giga Guru

Your current is the table on which the workflow is currently running.


current.variables.variablename is the right way to fetch all the variables that were declared in the catalog item and now


a part of the requested item. So generally this gets picked up from the Variable ownership table in correlation to the requested item.



current.variablename would also sometimes work if you had the same variable or in this case column name defined in the current table.



So if were to take the flow of catalog item to requested item, anything in the catalog item that you would like to refer


you would use the current.variables.variablename and anything in requested item table by itself you would use current.variablename


Sai Anna
ServiceNow Employee
ServiceNow Employee

"current" always gives access table columns. if you want to access any column on the table (for instance requested item table (sc_req_item), use



current.COL_NAME



variables which you create on catalog item are stored in a different table, in order to access variables on Requested item/Catalog Task table, use



current.variables.VARIABLE_NAME.



please refer Using Variables in a Workflow - ServiceNow Wiki   for more information




Thanks,


Sai


acg
Kilo Contributor

thank you all, very helpful...


Sai Anna
ServiceNow Employee
ServiceNow Employee

Can you make answer as Correct if it helps, so it helps other people to look in future?




Thanks,


Sai