Action

Gas Mileage

Posted by @nahumck, Last update almost 6 years ago

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

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
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.