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

The transform function itself is synchronous, but it receives data from an async source.

The problem should be  Transform executes BEFORE input data arrives

 

Add Defensive Checks


(function transform(input) {
// CRITICAL: Check if data has actually loaded

console.log('Transform executed at:', new Date().toISOString());
console.log('Input received:', input);
console.log('Input type:', typeof input);
console.log('Input is null/undefined:', input == null);

// Guard clause: Return empty structure if data not ready

if (!input) {
console.warn('Transform: Input is null/undefined - data not loaded yet');
return []; // or {} depending on expected output type
}

if (Array.isArray(input) && input.length === 0) {
console.warn('Transform: Input array is empty');
return [];
}

// Your transformation logic here

var result = input.map(function(item) {
return {
id: item.sys_id,
name: item.name
};
});

console.log('Transform output:', result);
return result;
})(input);

 

ADDITIONAL CHECK:

ServiceNow data brokers expose state properties you need to monitor:

// In your component or client script, check:


@Data.YOUR_INPUT_BROKER.isLoading // Boolean: Is data currently loading?
@Data.YOUR_INPUT_BROKER.hasError // Boolean: Did loading fail?
@Data.YOUR_INPUT_BROKER.error // Object: Error details if failed