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

acg
Kilo Contributor

sure, but where is this option to mark as correct? ideally both answers are good and fine with me which is why I checked liked...so I guess I have choose one? I think I have to email the admin to give me the option to mark as correct because I don't see the option available to me.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

dan.bruhn can help you with this issue.


I've updated this discussion to a question.



Thanks,


acg
Kilo Contributor

thanks


Abhijeet Mane
Tera Contributor

I faced the same and after some analysis i figured it out. will put in a simple way:-

current.variables.variable_name = use it when you want to fetch something from the form (catalog Item form which user will fill)

current.variable_name = use it to access something on the RITM

correct me if something is wrong! Thanks! 

i am not adding the table names here because other folks have already added them you can refer to them i tried to put it in a rookie way!