1 Reply · Latest reply on Jul 17, 2017 5:58 PM by Nathan Giere

    How to pass value from an UI macro to a variable

      Hi Everyone


      Before starting I would like to emphasize that I am new to servicenow, however I am very enthusiastic about learning this powerful tool.


      The first challenge that I have is about to know how to pass a value from an UI macro to a variable.

      I have defined the below two fields in the service catalog.



      The "Request Type:" field has defined around 8 values, I had to use a macro because the length of the values.




      • eSIR Member Accessibility (choose for visual, hearing, motor accessibility issues)
      • Opt Out Request (choose for non-member, member to no longer receive communications from ESI, or do not solicit)
      • Pharmacy Help Desk eSIR (Pharmacy Helpdesk Agents choose for claims, copay, deductible, out-of-pocket, drug coverage issues)
      • ..............
      • ............


      I would like to know how can I pass the value from the "Request Type:" macro field to the "Request Type from UI Macro" variable using an OnChange script


      In addition to this,  once I am able to pass the value from the macro to the variable, I want to display certain fields.


      if "Request Type from UI Macro" = "SIR Member Accessibility (choose for visual, hearing, motor accessibility issues)"


      The below field should be visible


      • Member Number
      • Member DOB
      • Member First Name
      • Member Zip Code


      Thanks in advance for your support, any help would be appreciated


      Fabian GR

        • Re: How to pass value from an UI macro to a variable
          Nathan Giere

          an onChange script can only reference a variable created through servicenow. I suggest creating a servicenow variable and doing it that way. not sure your reason for creating a custom ui macro for this. however, if this is not an option. you can create a onLoad Client script and add event listeners to watch your custom ui macro and set your value that way. I do not think this would be supported however in service portal.

          1 of 1 people found this helpful

          - Please like or mark as correct/helpful as you see fit.

          If you have any other questions please let me know.