- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016 01:22 AM
What are the options for executing code stored in custom tables using the Script field type?
I'll give a simple scenario:
I have a large (mostly static) JSON payload to submit to Slack. The dynamic data is updated using "macros". Each macro is a simple bit of JavaScript to collect the data from somewhere else:
for example: The Macro is called Color and presented in JSON as "${Color}"
answer = (function(myTask, inAction) {
var sColor = '#ff0000';
var nPriority = myTask.priority + '';
var sTemp = gs.getProperty('ppb.integration.slack.macro.Colors', '5:#66ff66,4:#3366ff,3:#ff6600,2:#ff33cc,1:#ff0000');
var aTemp = sTemp.split(',');
for ( var i = 0; i <= aTemp.length; i++ ) { var aRow = aTemp[i].split(':'); if ( aRow[0] + '' == nPriority ) { sColor = aRow[1] + ''; break; } }
return sColor;
})(myTask, inAction);
This is used to replace a "macro" in the JSON which would look something like this:
{"username":"${SlackUsername}","attachments":[{"title":"Short description","title_link":"${URL}","text":"${ShortDescription}","color":"${Color}"],"ts":"${TimeStampEpoch}"}]}
The question I have now is, what options are there to run the script in the Script field without using something like this:
gs.print('[' + answer + ']');
var F = new Function(glider.u_macro_script);
F();
gs.print('[' + answer + ']');
There's a separate process for matching the macro values in the end...
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016 03:31 AM
Hi Iain,
You might find this useful. See the attached lab guide and use the URL below for the repository.
It was a self-paced lab I built for CreatorCon 16 to introduce you to using Script fields. It requires you have a GitHub account. Fork the repository, then go in to Studio and import the repository. The only major difference between the attached lab guide and now is that we won't be providing an instance for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2019 08:16 AM
Yes, it was there the entire time. I am not sure how I missed it. Thank you.