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

Marc Mouries
ServiceNow Employee
ServiceNow Employee

In my example, I will read and write a create a system property "date_format" in my application "UIB Examples" which scope is "x_snc_uib_examples". (If you're trying to change a Global system property it will require a separate discussion)

Let's create our own system property:

  1. Navigate to System Properties > UI Properties (sys_properties.list)
  2. Then create a new property and set the following values:
    1. name = "date.format"
    2. scope= your application
    3. type = string
    4. value = dd-mm-yyyy
    5. read & write = Add the role snc_internal

Once the property is created or you have a similar property or field to update, follow these steps:

  1. In UIB, Create a new data resource (db icon on the left > "Data resources" > (+ New) > Transform
    1. this opens a new page
    2. Note, for non-system, we could use the out-of-the-box data resource "Look up record"
      1. Name = getSystemProperty
      2. Description = Returns the system property
      3. Properties =
        [{ "name":"propertyname",  
          "label":"Property Name",
          "description":"Name of the system property",
          "readOnly":"false",
          "fieldType":"string",
          "mandatory":true,
          "defaultValue":""}]
      4. Script
        function transform(input) {
        if (!input.propertyName) return {"error" : "missing property name"};
        var rec = new GlideRecord('sys_properties');
        rec.addQuery('name', input.propertyName);
        rec.query();
        if (rec.next()) {
        return {
        value:"" + rec.value
        sysId: rec.getUniqueValue()
        };
        } else {
        return {"error": "property not found."};
        }
        }
      5. Then click Submit

  2. Go back to the UIB Page
  3. You should see the message "Data resources have changed outside of UIB"
  4. Click Update Page
  5. Add the new data resource to your page
    1. go to Data resource instances (database icon on the left toolbar)
    2. in the first column, select your application
    3. select getSystemProperty
    4. Click Add
    5. You should see an error message "You don’t have permission to select this data resource. Contact your admin for more information". We'll fix that
    6. Open your getSystemProperty data resource
      1. if you closed it, in the classic explorer, search for sys_ux_data_broker_transform.list
      2. Open "getSystemProperty" 
      3. Click on the menu ☰
      4. Click on "Copy Sys id"
      5. Elevate your role to "security admin" (if you don't have the security admin role, ask the admin to create the ACL for you)
      6. in the classic explorer search for ACL, select Access Control (ACL)
      7. Click New and then set the following values:
        1. Type: ux_data_broker
        2. Operation: execute
        3. Name: <the sys_id of the data resource> we copied earlier
        4. Role: double-click and add the role of the app user or simply 'snc_internal'
      8. Click Submit
    7. Back to UIB 
  6. You should see the result of the data broker = {"error": "missing property name"}
  7. It's normal we need to set the name of the property we need.
  8. in the data source, set property name to "x_snc_uib_examples.date_format"
  9. Your screen should look like
    find_real_file.png

  10. Bind the data resource to the input field
  11. Select the input field
  12. then select the value field in the component's config panel on the right
  13. Select the database icon (dynamic data binding)
  14. Set the value to "@data.getsystemproperty.output.value"
  15. Your screen should look like
  16. find_real_file.png
  17. Notice how the field is populated with the correct value. The reading of the record field is done. Let's move on to the saving part

 

See Part 2: How to update a record with the value from a field in UI Builder?

 

Comments
Community Alums
Not applicable

Thank you very much for this article! It is very helpful and very complete!

Marc Mouries
ServiceNow Employee
ServiceNow Employee
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

Marc Mouries
ServiceNow Employee
ServiceNow Employee

@Thiago Pereira  The ACL to execute the data broker does not require snc_internal. I just added snc_internal in case you don't have a pre-defined role. It's always recommended to use your app's roles instead. Ultimately the ACL about the records that will be queried in the data broker will be enforced so there is no risk of data leakage IF the roles are properly set up. 

 

Version history
Last update:
‎05-26-2022 07:22 PM
Updated by: