How to set How to call a Sy property from a JSON Code

Ashish Kathait
Tera Contributor

I have a UX Macroponent Definition  https://Yourinstance.service-now.com/sys_ux_macroponent.do?sys_id=6295cbe0c3b57250eee1fe8f050131bd&s...

 

In State variable I want to replace 7 from below query and set it from sys property dynamically but how to call it 

 

"initialValue": {
"type": "JSON_LITERAL",
"value": "sys_created_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()"
},

 

 

I have tried calling a script include but not working.

3 REPLIES 3

Grzegorz Kaznoc
Tera Contributor

You can try call script include when it is Client callable. Make sure this is checked and dont forget about security as client callable script includes can be called by any user. Refer to ApprovalDelegationUtil script include used ootb for My Approvals module

kaushal_snow
Giga Sage

@Ashish Kathait ,

 

In servicenow you can’t directly reference a sys_property inside the static json of a ux macroponent initialValue field...instead you can expose the sys property value via a client callable script include or server logic and......return that value to the json state....

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Technical Consultant/Developer

Dinesh Chilaka
Tera Guru

Hi @Ashish Kathait ,

Here it is not possible call the System Property and Script Include Directly.

In UI Builder Pages , if we want to execute any Server side scripts we Just need to Create a new Transform Data Broker .

Refer the below documentation on how to create the Transform Data Broker

https://developer.servicenow.com/dev.do#!/learn/courses/xanadu/app_store_learnv2_uibuilder_xanadu_ui...

In that data broker call your script include or write your logic there and return your result.

Let me know if you need any Guidance.

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