Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to define properties fieldType with JSON type in now-ui.json

phong nt
Tera Contributor

I create custom component for UI builder. This component is similar to Data Set component. Properties in now-ui.json is defined below:

 

"properties": [
{
"name": "list",
"label": "data",
"description": "Array list",
"readOnly": false,
"defaultValue": "[{rfcId:\"RFC-001\",subject:\"subject\",url:\"google.com\",createTime:\"2022-04-21\"}]",
"typeMetadata": {}
}
]

I just want to pass a json object to this component from UI builder like Data Set component  but this config is not work.

My comonent can not recognize it is json but just string so can not binding it with a list of div I defined in ui code.

Maybe I miss filedType or something else.

Any suggest? Thanks.

2 REPLIES 2

Teju Dhoran
Kilo Sage

Hi,

Are you building JSON dynamically?

"properties": [
{
"name": "list",
"label": "data",
"description": "Array list",
"readOnly": false,
"defaultValue": [{rfcId:\"RFC-001\",subject:\"subject\",url:\"google.com\",createTime:\"2022-04-21\"}],
"typeMetadata": {}
}
]

 

In default value you are passing "defaultValue": "[{}]" instead pass  "defaultValue": [{}].

and correct default value format is:

[{"rfcId":"RFC-001","subject":"subject","url":"google.com","createTime":"2022-04-21"}]

 

Please mark helpful and correct if applicable.

Thanks,

Teju D

thomas997786320
Tera Contributor

maybe 4 years later, it's too late, but for people searching for it:

Set fieldType to "json":

{
        "name": "configAria",
        "label": "ARIA properties",
        "fieldType": "json",
        "readOnly": false,
        "defaultValue": "{}",
        "description": "Configures ARIA properties",
        "selectable": false,
        "valueType": "string",
        "mandatory": false
    }

thomas