2 followers Follow

Use variables in scripts in custom panels



I'm trying to build a custom panel that uses the API to do a query related to the selected item in screen, but the documentation doesn't really explain how to use the "advanced" section of the custom panels definition. I need to get the id of the parent project of the selected task and then do a query with this value. However, I'm not able to put this id as a javascript variable to properly build the query. If I use the HTML section and put a "<script>" tag it gets removed. In the script section I cannot use variables. And finally in the data section (JSON format) it says I can use variables but they don't really get evaluated. I don't even know how it is possible to mix curly brackets from the JSON objects and the Clarizen formulas and still make sense of it. Can you please help me?


Thanks in advance.

Fernando Borrego Polo Answered

Please sign in to leave a comment.




Since this is a Custom Panel/API question, please post this question in the Developer section of the forum so that the correct Engineers have eyes on it and are able to provide you the best possible response. 




Boris Krutiy 0 votes
Comment actions Permalink

Sorry about that, We are working on competing the custom panel docs.
Let's do some order first:
The HTML part must contain only pure html (no script) and can contain variables.
The Script part is static and can not contain variables.
The data part is where you can render dynamic data that can later be used by the custom panel script.
Because JSON uses curly brackets ({ }) as part of its format, this specific formula field uses double brackets to indicate a formula. So, a data section rendering the id of the parent project might look like this:
{"parentId" : {{$project.ExternalID} }

Note that to begin a formula you use double brackets but to end it you use a single one.

Eyal Post 0 votes
Comment actions Permalink

Good to know, thanks for the explanation :).

Fernando Borrego Polo 0 votes
Comment actions Permalink