Eval Draft

Posted by @jtokash, Last update over 1 year ago

// Does a JavaScript eval on the current draft and puts the result at the bottom of the draft.
// Some examples:

var output = “”;

output += “Model: ”+device.model+“\n”;
output += “OS: ”+device.systemName+“\n”;
output += “OS version: ”+device.systemVersion+“\n”;
output += “Battery level: ”+device.batteryLevel+“\n”;

function getContentsOfURL(url){
var http = HTTP.create();
var response = http.request({

if (response.success) {
    var text = response.responseText;
    var data = response.responseData;
return text;


var stockData = JSON.parse(getContentsOfURL(“https://api.iextrading.com/1.0/stock/AAPL/quote”));

output += “\n”+stockData.symbol+“: ”+stockData.latestPrice+“\n”;

// End your script with the variable you’d like to see in the result.


Model: iPad
OS version: 11.2.5
Battery level: 0.8299999833106995

AAPL: 172.5


  • script

    // See online documentation for examples
    // http://drafts5-help.agiletortoise.com/
    var endOfCodeMarker = "//-//";
    var code = draft.content;
    var indexOfResultMarker = draft.content.indexOf(endOfCodeMarker);
    	code = draft.content.substring(0,indexOfResultMarker);
    var output = eval(code);
    draft.content = code + endOfCodeMarker+"\n\n"+ output;


  • After Success Default
    Notification Info
    Log Level Info
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.