Pass values into a UI Macro on a Record Producer

Constantine Kr1
Giga Guru

How do I pass variables into a UI Macro that is being used by a record producer?

I have created a UI Macro that I use in UI Pages, Actions, etc... that accepts multiple parameters in order to run. I would use the following to make it work on something like a UI Page:

<g:myCustomUiMacro varCarType="Ellio" varMpg="80" />

However, how do I do the line above inside a variable in a Record Producer? Screenshot of the place I am referring to in ServiceNow.

find_real_file.png

Thanks

1 ACCEPTED SOLUTION

siva_dirisala
ServiceNow Employee
ServiceNow Employee

Hello Constantine, are the values that you need to pass to your macro fixed at the time of the service definition or are they based on the runtime values that user enters in other variables? If it is the former, then you can wrap your macro in another macro and pass the static values. If it is the later, then you need to use Client script access to variable fields on task records           API to access those values. The reason for this, in case you are wondering, is that the macro is evaluated on the server side while the user entered variable values are on the client-side.


View solution in original post

4 REPLIES 4

Geoffrey2
ServiceNow Employee
ServiceNow Employee

So is the issue here that you have created a UI Macro called myCustomUiMacro, but you can't select it in the Macro field on a Variable?


And your UI Macro looks like this?:


Capture.PNG


Has someone added a Reference Qualifier to the Macro field?


Hi Geoffrey,


I am able to select the UI Macro, and it loads fine... but I can't pass in data to it (as in the example above, varCarType="ellio", I am unable to pass that data in.


siva_dirisala
ServiceNow Employee
ServiceNow Employee

Hello Constantine, are the values that you need to pass to your macro fixed at the time of the service definition or are they based on the runtime values that user enters in other variables? If it is the former, then you can wrap your macro in another macro and pass the static values. If it is the later, then you need to use Client script access to variable fields on task records           API to access those values. The reason for this, in case you are wondering, is that the macro is evaluated on the server side while the user entered variable values are on the client-side.


Thanks Siva. The values are static in this situation... and wrapping it in another UI macro definitely does the trick. I was hoping there was syntax sugar that would not require another UI Macro to be written.... but I am happy that I have this working now. Thanks!