Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

UI Builder client handler how pass url

armanoj
Mega Sage

Hi team,

 

I want pass url in UI Builder client handler.
when hardcoded its redirecting but there multiple upper instance UAT, Prod , it is not proper to hardcode. please suggest a solution call url of current instace to 
UI Builder client handler

17 REPLIES 17

UI Builder client handler

@armanoj ,

If you are trying to open the page that is already present in that workspace use the OOB Open Page or URL  event handler, here ServiceNow automatically prepends whatever active instance URL (Dev, UAT, or Prod) the user is currently on.

If my response helped, mark it as helpful and accept the solution.

Thanks,

Dinesh

Vishnu Surendra
Tera Expert

Hi @armanoj 

For your requirement, you need to use a server-side script in UI Builder to retrieve the current instance ID. However, this cannot be done directly in UI Builder. You need to create a Data Broker Server Script to fetch the current instance ID.

Steps to Configure the Data Broker Server Script

  1. In the Application Navigator, search for Now Experience Framework and select Transforms.
  2. Click New and create a new Transform/Data Broker Server Script with a name of your choice.
  3. In the Properties field, provide an array of inputs if required. For this requirement, inputs are not required, so you can leave it empty.
  4. In the Script section, add the following code:
function transform() {
    return {
        "instance_URL": gs.getProperty("instance_name")
    };
}
  1. In the Output Schema section, add the following:
{
    "type": "object",
    "properties": {
        "instance_URL": {
            "type": "string"
        }
    }
}
  1. Save the record and copy the sys_id of the Data Broker Server Script.

Configure the ACL

  1. Navigate to Access Controls (ACLs) and create a new ACL.
  2. Set the Type to:
ux_data_broker
  1. Set the Operation to:
execute
  1. Next to the Name field, click the small blue icon. In the placeholder, enter the sys_id of the Data Broker Server Script that you copied earlier.

Important: Remove the * that appears before the sys_id in the placeholder. The Name should contain only the Data Broker's sys_id.

  1. In the Requires role section, select the appropriate role for the users who need to execute the Data Broker, and save the ACL.

Use the Data Broker in UI Builder

  1. In UI Builder, create a Client State Parameter as required.
  2. In the Data Source section, click (+), search for the Data Broker Server Script you created, and add it as a data source.
  3. Bind the required value from the Data Broker to the Client State Parameter you created.

The Data Broker will return only the instance ID, for example:

dev123456

If you need the complete instance URL, you can construct it by adding the required domain:

https://dev123456.service-now.com

Therefore, the final URL can be constructed using the instance ID returned by the Data Broker.


please refer below video 
https://youtu.be/QrTc8PTOHmc?si=liyumu-eeKEfL7xs

If my response helped, mark it as helpful and accept the solution.



Welcome to our comprehensive tutorial on Transform Data Broker and creating a UI Builder in ServiceNow! 🎉 In this video, we'll walk you through: ✅ What is a Transform Data Broker and its role in ServiceNow. ✅ How to design and configure custom UI Builder components for seamless data integration. ✅

I created the data broker unable to add in ui builder . new data broker there add button not visible. 

Hi @armanoj , 

Do you mean add button not visible in the ui builder for adding the created data broker? 

 

You can directly add the created data broker in the ui builder by going to left side  Data source click + sign

Then type your Data broker name created. 

 


If my response helped, mark it as helpful and accept the solution.