UI Builder: Issue with Local Data Resource

gsimoes
Tera Contributor

Hello,

I'm trying to make a modification to our landing page in Service Operations Workspace.  Basically, we've added a user field for "nickname" and we want to use that instead of the firstName that it defaults to.  I setup a local Data Resource that queries the sys_user table to get this information, but when I try to update the initialization script, it crashes when trying to read this value.  If I go to the pill selector it is: data.look_up_nickname.result.nickname.value, so I've tried adding code for api.data.look_up_nickname.result.nickname.value, but it just crashes. I know the rest of the coding works, because if I hard code a name "like x = 'Smith'" then it does exactly what is expected, but only fails when trying to read from the local data resource.  I've also replaced the dynamic text component with the local resource directly in the interface, so I can see that the data does exist, it's only when trying to read from the local data resource IN client script that I am having issues.  Any suggestions?

1 ACCEPTED SOLUTION

Hi Simoes,

It seems so.

 

1. Create a client state "nickName".

Manoj89_0-1751092166386.png

 

2. Update client state with returned value when the data fetch succeeded

Manoj89_1-1751092749429.png

3. Use the client state in your landing page, this way it works async.

 

 

 

View solution in original post

10 REPLIES 10

Shruti
Mega Sage
Mega Sage

Hi,

You can concatenate "Hello" and output of new data resource

Shruti_0-1751028068601.png

 

But why does this code not work?

gsimoes_0-1751030833847.png

 

Manoj89
Giga Sage

Hi Simoes,

 

Usually, the results are returned in Array of objects, maybe try api.data.look_up_nickname.result[0].u_user_nickname.value

gsimoes
Tera Contributor

Hi Manoj,

Thanks for the suggestion. Looking at other examples, I tried that, but still failing. Looks like it is throw an error in the browser console that result is undefined.  (whether using the array index or not)