- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 04:36 PM
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.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 10:32 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 05:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2016 04:13 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 10:32 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2016 03:05 PM
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!