How to read the assets json file.
I have added json file in assets folder.
File Name: Client_Config.json
{
"ClaimStatus":"Claim Status",
"InitiateNonQualified":"Initiate Non - Qualified Death Claim"
}
How to load these file in Script.js or forms.hbs and get the value of "ClaimStatus" ??
-
Hi Vishwanath,
Just to clarify, are you referring to the guide help center code editor?
-
Hi Tipene,
Yes, I'm referring to the guide help center code editor.
-
Thanks for update!
Unfortunately you can’t render json data uploaded as an asset directly in the script.js or .hbs templates. A couple of options could be to store the data as an object directly in the script.js file and push the data to your templates from there, or you could store the data externally and make a call to retrieve it in your script.js file.
Let me know if you have any questions!
Tipene
-
Hi Tipene,
Could you please tell me how to do 2nd options i.e. "could store the data externally and make a call to retrieve it in your script.js file."
-
Hi Vishwanath,
This wouldn't be a Zendesk specific process to implement. Essentially, with the 2nd option you'd want to look at using a backend database where you could store the information you want to access, then fetch the data by making a call to the database API in your script.js file. A quick Google search should return some good resources that will get you moving in the right direction.
Please sign in to leave a comment.
5 Comments