Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to use custom data resource in UI builder?

Sachin bagyal
Tera Contributor

I have made a custom data resource of transform type and not able to get the data in UI builder when I use that data resource.

5 REPLIES 5

dhoang22
Tera Contributor

I am currently learning UI Builder and would also like to know if there is a way to call a Script Include to retrieve data by creating a Data Source?

ahmedt
Tera Contributor

MaxMixali
Kilo Sage

For my experience you can try this list of operation: Hope that can help

Max

Checklist to Fix Transform Data Resource:
1. Verify Your Transform Script Returns Data
Your transform script MUST explicitly return data:
javascript(function transform(input) {
// Process your data
var result = input; // or your transformation logic

// MUST HAVE: explicit return statement
return result;

})(input);
2. Check Input Configuration
Transform data resources require an input source:

Open your Transform data resource in UI Builder
Check the Input section - it should have a source configured
Verify that input source is actually returning data

Test the input first:

Temporarily bind your component to the INPUT data resource (not the transform)
Confirm the input data is actually loading
If input is empty, your transform will also be empty

3. Add Debugging to Your Transform
Modify your script to see what's happening:
javascript(function transform(input) {
// Debug: Check what you're receiving
console.log('Transform Input:', input);
console.log('Input Type:', typeof input);
console.log('Is Array:', Array.isArray(input));

// Your transformation
var result = input; // or your actual transformation

// Debug: Check what you're returning
console.log('Transform Output:', result);

return result;

})(input);
Then check the browser console (F12) when the page loads.
4. Common Transform Script Patterns
If transforming an array of records:
javascript(function transform(input) {
if (!input || !Array.isArray(input)) {
return [];
}

return input.map(function(item) {
return {
id: item.sys_id,
displayName: item.name,
customField: item.some_field
};
});
})(input);
If transforming a single record:
javascript(function transform(input) {
if (!input) {
return {};
}

return {
fullName: input.first_name + ' ' + input.last_name,
email: input.email
};
})(input);
5. Check Component Data Binding
In your component configuration:

Select the component (repeater, list, table, etc.)
Check the Data property
Correct binding format: @Data.YOUR_TRANSFORM_NAME.output

Note: For Transform type, you typically bind to .output not .results
6. Verify in Data Resource Panel

In UI Builder, open the Data and scripts panel (left sidebar)
Find your Transform data resource
Look for any error icons or warnings
Click to expand and check the configuration

7. Test with Minimal Transform
Start simple to isolate the issue:
javascript(function transform(input) {
// Just pass through - no transformation
return input;
})(input);
If this works, gradually add your transformation logic back.

ahmedt
Tera Contributor

Hi @MaxMixali 
Frist of all thanks for you response and time 
Second,from what i know all data broker is async so i want to make sure I catch the value before taking the action