UI Builder Scriptlet Data resource with @data.record.form as input

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 12:34 PM
I'm running into an issue when trying to use @Data.record.form as an input for a scriptlet datasource and I'm hoping someone can shed some light.
I have a scriptlet that I want to use to parse the @Data.record.form data and reformat the glide lists into a format that can be easily consumed by the pill list component.
I have created the scriptlet and added a single input of the object type that I into which I pass the record.form object.
The problem is that when the form loads in the UI builder interface I get the error
"sourceName": "ad4e0502879a2910a9f875d8dabb3552",
"lineNumber": 2,
"columnNumber": 0,
"errorMessage": "\"$__input$__data_record\" is not defined.",
"name": "ReferenceError",
"message": "\"$__input$__data_record\" is not defined.",
"localizedMessage": "\"$__input$__data_record\" is not defined.",
"scriptStackTrace": "\tat ad4e0502879a2910a9f875d8dabb3552:2\n",
"scriptStack": [
{
If at this point I change the "When to evaluate this data resource" to either Explicit or Eager, the script evaluates and runs fine and gives the output expected. But every time, on initial load I am getting the error above that input.data.record is not defined, causing the components that consume the data to fail to render.
I have tried changing the Scriptlet resource to run only when invoked (explicit) and then in the standard record, adding a "Record Data Fetch Completed" event to refresh the scriptlet data source, trying to ensure that it only runs when the source object has become available, but still no luck.
I've tried to eliminate my scriptlet code being the issue by simply returning the input back as well.
Scriptlet Properties
[
{
"name": "data_record",
"label": "Record JSON",
"description": "Output of Standard Record Lookup",
"readOnly": false,
"fieldType": "object",
"mandatory": true,
"defaultValue": ""
}
]
Scriptlet Script:
function transform(input) {
return input;
}
Even with just this, it never evaluates the scriptlet properly on initial page load and always errors with that error referenced above until I manually make it re-evaluate by changing the "When to evaluate this data resource" setting in the resource.
Any thoughts on how to ensure that this scriptlet only runs once that data record is defined and available?
Thanks!