how to call script include from ux client script include

khadir
Kilo Contributor

i have one ux client script include where iam calling script  include using glide ajax, can any one tell me whether it is the correct process or not  because iam not getting response.

 

find_real_file.png 

and in ui builder i have one client script there i am exporting ux client script include.

 

find_real_file.png

thanks in advance.

 

6 REPLIES 6

Patrick Witt
Tera Contributor

Hi Khadir,

 

did you find a solution for your problem or a work around? We have the exact same requirement.

 

Greets

Hi Khadir,

I was able to solve the requirement. The short answer is: You cannot.
However: You can most certainly achieve what you want in a different way, by using a Data Resource.

To execute Server-Side code from a workspace you use Data Resources. If there is no OOTB Data Resource that solves your problem, simply create one by yourself. Data Resources come in different types, such as GraphQL, Transform and more. Data Resources are defined in the Data Broker table in ServiceNow. To execute Server Side Code, we need a Transform Data Resource.

Navigate to sys_ux_data_broker_transform and create a new Record. Configure the record to your requirements. In the script field enter the code you want to execute within a function.

 

 

function transform(input){
        
       // Your Code goes here
       // You can call all Server-Side APIs and fuctions, including Script Includes.

	// return '';
}

 



After you created the Data Resource, it should be available in the UI Builder. However, ACLs must be configured before you can use the Data Resource. Create a new Access Control select ux_data_broker as type and execute as operation.

 

Witt1_0-1696932689086.png

After you created the Data Resource, it should be available in the UI Builder. However, ACLs must be configured before you can use the Data Resource. Create a new Access Control select ux_data_broker as type and execute as operation.

As name you enter the sys_id of the previously created data resource. If the dropdown selection is present, click on the little blue triangle next to name. Doing that you should be able to enter your sys_id.

Configure the roles for the ACL and submit the new Access Control. Your Data Resource is now fully configured, and you can use it in a Workspace Page. E.g., Trigger the script by adding an event mapping to a button and select your data resource.

I hope this helps you!

Please mark this as helpful if it solved your problem.

Greets