The CreatorCon Call for Content is officially open! Get started here.

Max Selwyn
ServiceNow Employee
ServiceNow Employee

Create Data resource to populate dropdown components on public page

For non public pages, see: this article

 

Create your own transform data resource.

  1. On the Data resource tab, click the add button.
  2. Select Global, and click New.
  3. Select Transform.

 

You will need to build an object with ‘id’ and ‘label’ properties.

  1. Create a script similar to the below example
  2. Be sure to place the object in an array and return the array in your function

MaxSelwyn_0-1685637690113.png

 

 

  1. Navigate to ACLs. (you will need security_admin role for the next step)
  2. Elevate to security admin and create a new ACL.
  • Type: ux_data_broker
  • Operation: execute
  • Name: the sys id of your data resource
  • Roles: public

(click the arrow next to the Name field if it doesn’t change from the dropdown)

 

MaxSelwyn_1-1685637690116.png

 

 

Save the ACL.

 

Bind the output to your dropdown component.

  1. In the config pane of the dropdown component, bind your output to the ‘items’ field.
    1. @Data.your_date_resource_name.output

MaxSelwyn_2-1685637690117.png

 

 

Create a reference qualifier data resource for use on component

Follow the above steps to create a new transform data resource

  1. In the properties field, enter a property to allow you to pass in input.

[

{

"name": "records",

"label": "Enter a Sys Id",

"fieldType":"string",

"readOnly":false

}

]

In the script, you will call your input, which will be the name of the input property. In my example, ‘records’ is my input name.  You will create a gliderecord to lookup the dependent values from your parent value, which comes from your input property.

 

MaxSelwyn_3-1685637690121.png

 

 

Save the data resource and create an ACL.

 

  1. Navigate to ACLs. (you will need security_admin role for the next step)
  2. Elevate to security admin and create a new ACL.
  • Type: ux_data_broker
  • Operation: execute
  • Name: the sys id of your data resource
  • Roles: public

(click the arrow next to the Name field if it doesn’t change from the dropdown)

 

MaxSelwyn_4-1685637690123.png

 

Save the ACL.

 

In UI Builder, add your data resource to your page.

 

  1. On the data resources tab, click the add button.
  2. Find and select your application scope in the lefthand pane.
  3. In the middle pane, you will see your new data resource under the Transform section.
  4. Select it and click add in the right hand pane.
  5. You will not see any output at this point.
  6. Create a client state parameter to hold the ‘parent’ you will use to find the children options.

 

MaxSelwyn_5-1685637690124.png

 

  1. Back in your new reference qualifier data resource, bind your client state parameter to the input field you created.

MaxSelwyn_6-1685637690128.png

 

Now you need to update your client state parameter when an item is selected in the first dropdown.

 

  1. Click your dropdown ‘parent’ component.
  2. Select the Events pane.
  3. Select the ‘Dropdown selected items set’ event.
  4. Click Add a new event handler
  5. Select ‘Update client state parameter’ under Page-level event handlers
  6. In Client state parameter name, enter your client state parameter name.
  7. In the New Value, data bind the payload value.
    1. @payload.value
  8. Click apply.

 

MaxSelwyn_7-1685637690135.png

 

 

  1. Bind the output of your reference qualifier data resource to your 2nd dropdown component.

 

MaxSelwyn_8-1685637690136.png

 

 

Now your 2nd dropdown will be dependent on the first dropdown value.

 

 

Comments
Nolan Thaxton
ServiceNow Employee
ServiceNow Employee

Great post, very helpful

Thiago Pereira
Tera Contributor

Hi!

 

I did not find any documentation about this type of ACL and i have some doubts about how it works.

The application I am working contains strictly confidential information from our client and we would like to know more about how this type of ACL works as it needs the "snc_internal" role to work.

Is there any risk of data leakage?

 

best,

Thiago

Max Selwyn
ServiceNow Employee
ServiceNow Employee

@Thiago Pereira This ACL gives permission to execute the data broker (data resource). I have not tested it out, but I would assume you can add your roles/conditions like you would with any other ACLs.  I would recommend testing that out and setting the page audience properly, to avoid any issues of the page not working for those who are unable to see the data. 

Version history
Last update:
‎06-01-2023 09:47 AM
Updated by:
Contributors