Drafts Action Directory

Gas Mileage

Posted by @nahumck, Last update 5 months ago

Gather some information about gas mileage in a prompt step and create a draft with that information.

Install

Steps

  • script

    //Gas Mileage Example
    
    // Prompt for trip information
    
    var p = Prompt.create();
    p.title = "Enter Gas";
    p.message = "Enter the gallon info"
    p.addTextField("gallons", "Gallons", "",{"keyboard":"numberPad"});
    p.addTextField("trip", "Trip A", "",{"keyboard":"numberPad"});
    p.addTextField("mpg", "MPG", "",{"keyboard":"numberPad"});
    p.addButton("Go");
    var con = p.show();
    
    if (con) {
    	// Get values from prompt step
    	var gallons = "Gallons: " + p.fieldValues["gallons"];
    	var trip = "Trip A: " + p.fieldValues["trip"];
    	var mpg = "MPG: " + p.fieldValues["mpg"];
    
    	// Create Draft
    	var d = Draft.create();
    	d.content = "# Trip Info" + "\n" + gallons + "\n" + trip + "\n" + mpg; 
    	d.update();
    	editor.load(d);
    }
    else {
    	context.cancel();
    }

Options

  • After Success Default
    Notification Info
    Log Level Error

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.