How to call the data resource from Client Scripts UI Builder

mohammedghouse
Giga Guru
Hello All,
I have define the state parameter "atternityLink" its type is string and have given initial value to that link. 
Below is the client script where I am trying to set the state value but not working. But everytime I am getting the same value which I have provided as initial value.
const
 userId = api.data.caller_info.result.user_name.value;
    const ciName =  api.data.device_info.results.name.value;
    urlLink = "URLSTRING1" + ciName+ "URLSTRING2" + userId +"URLSTRING3"
    api.setState("atternityLink",urlLink)
 
data.caller_info.result & api.data.device_info.results are local data resources . 

Thanks 
Mohammed Ghouse

9 REPLIES 9

AshishKM
Kilo Patron
Kilo Patron

Hi @mohammedghouse ,

You can try as below

urlLink = "URLSTRING1" + ${ciName}+ "URLSTRING2" + ${userId} +"URLSTRING3"
    api.setState("atternityLink",urlLink)
 
AshishKMishra_0-1702239920735.png

 

-Thanks,

AshishKMishra

 

Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM , 

 

Tried this not working 🙂

 

IronPotato
Mega Sage

Hi @mohammedghouse ,

 

my guess would be that you are using CONST. So you are not allowing the variable to change dynamically. Change your variables to either let or var.

@IronPotato

 

Tried with both types let or var, But no luck..