How to get the NAME of a sc_req_item variable via a business rule ...

Zod
Giga Guru

Hi,

I need to get the NAME of the variable of a requested item ... .

The BR runs on the sc_req_item table after insert ... but I'm not able to access the NAME of the variable. 

If I WOULD have the name of the variable I could access it via gs.info(current.varriable.testvariable) what would show the VALUE of the Variabler (not the sys_id) ... 

But what I need the the NAME of the variable that has been requested ... .

Currently it looks to me like I would have to check a bunch of tables like 

sc_item_option_mtom > sc_item_option > item_option_new ... to finally getting the name of the variable ...

 

Is there not more easy way???

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vem,

Why you need name of the variable. I assume you would require value stored in that i.e. current.variables.<variableName>

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Zod,

Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

no ... ;-(

 

As I was not looking for the value of a variable but was asking how to get the NAME for the variable ... 

Without the name - I can not get the value 😉

 

As the variables will be created automatically I was looking for some way to get the name within the further process.

But somehow I managed it .. not sure how right now. To long ago.

Thnx anyhow for trying.

Maniraj Jayaraj
Tera Expert

Hi Zod,

 

You can access all your variable names values using, current.variables object.

 

like , in business Rule you can try

 

for(var field in current.variables)

{

gs.log(current.variables[field]); //gives you the values of each variable in loop

gs.log(field); //gives you the variable name of each variables in loop

}

 

try it, mark correct if it solves your issue.

 

Thanks,

Maniraj Jayraj