Current.Variables.Variablename returning undefined in Business rule

kailashthiyagar
Kilo Guru

I m using a Business rule in my catalog item. I try to access the variable in my catalog item inside the Business rule as

current.variables.select_the_macro but its returning undefined..

I have one script include that executes as part of the workflow for that particular catalog item.. in that script include i m using as current.variables.select_the_macro.. There it works perfectly fine but not inside the BR..

So within BR, is there a different way to access the Catalog item Variable?

1 ACCEPTED SOLUTION

You should be using current.request_item.variables.variable_name



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

12 REPLIES 12

Make sure the variable is visible on catalog task.



Or make the variable global by marking it global in the variable itself.



Please mark this response as correct or helpful if it assisted you with your question.

sanjivmeher



The variable's visibility is set everywhere..but how to access it in the BR....i m writing the BR on sc_task table.


You should be using current.request_item.variables.variable_name



Please mark this response as correct or helpful if it assisted you with your question.

XYZ
Tera Contributor

This  solution isn't working fine for me. I tried this solution to fetch "requested_for" variable from catalog item, but its not taking. Please review it and correct me .

I have also attached the screenshot of my output Im getting.

 

(function executeRule(current, previous /*null when async*/) {

current.short_description="This catalog item is ordered for"+current.request_item.variables.requested_for;

})(current, previous);

Hello Kailash,



It looks like the variables are not visible on the task table. Either you can make those variables visible by selecting all the variables at catalog task level(by editing the workflow) if not you can fetch from request item as current.request_item.variables.select_the_macro



Edit: GlideRecord is not required.