Action

Multiple contacts to Cardhop

Posted by Jordan Ward, Last update over 5 years ago

Send each line of the current draft to cardhop to be parsed as a contact. Return to Drafts when complete. Don’t worry if part of the contact bleeds on to the next line. The action separates each contact when ‘return’ is pressed.

Steps

  • script

    // split draft into lines
    const lines = draft.content.split("\n");
    const baseURL = "x-cardhop://x-callback-url/parse";
    
    // loop over lines and send each to Cardhop
    for(var line of lines) {
    	if (line.length == 0) { continue; }
    	// create and configure callback object
    	var cb = CallbackURL.create();
    	cb.baseURL = baseURL;
    	cb.addParameter("s", line);
    	cb.addParameter("add", "1");
    	
    	// open and wait for result
    	var success = cb.open();
    	if (!success) {
    		if (cb.status == "cancel") {
    		   context.cancel();
    		   break;
    		}
    		else {
    			context.fail();
    			break;
    		}
    	}
    }

Options

  • After Success Archive
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.