WorkFlow Code Engine Help

Options
GregLaRose
GregLaRose Member
edited April 29 in Workflows

Good morning,

I am following along with the below Workflow Onboarding video from Dan. He mentions having a separate video for making a new code engine package, this one titled Page Manipulation, I was wondering if anyone had the link to that video, if it exists?https://domosoftware.sharepoint.com/sites/ProductMarketing/_layouts/15/stream.aspx?id=%2Fsites%2FProductMarketing%2FShared%20Documents%2FBy%20Product%2FWorkflows%2FCompleted%20BOM%2F23%2Dworkflows%2Donboarding%2Dv4%2Emp4&ga=1&referrer=StreamWebApp%2EWeb&referrerScenario=AddressBarCopied%2Eview

Thanks,

Greg LaRose

Tagged:

Best Answer

  • MattTheGuru
    MattTheGuru Contributor
    Answer ✓
    Options

    I recreated the codeengine function that you are asking about.

    Loom example: https://www.loom.com/share/273ffd4a40324cb4af5ef9fe77844e31

    Exact code:

    ______________

    http://const codeengine = require("codeengine")

    async function addUsersToGroup(group, person) {
    try {
    const url = `/api/content/v2/groups/${group}/user`;
    await codeengine.sendRequest("put", url, [person]);

    return true;
    } catch (error) {
    throw new Error(error);
    }
    }

    module.exports.addUsersToGroup = addUsersToGroup;

    _________________

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.
    Please accept the answer if it solved your problem.

Answers

  • MattTheGuru
    MattTheGuru Contributor
    Options

    I am not sure where Dan H.'s is, but here is a quick tutorial on how you can make your first Code Engine function. Let me know if there is a particular part of the setup you'd like help with!

    Loom tutorial: https://www.loom.com/share/3901d6ef80074f389ab56044a8d9b3f5?sid=372f0349-56c3-4497-a1bc-9121b3ce1385



    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.
    Please accept the answer if it solved your problem.

  • GregLaRose
    GregLaRose Member
    Options

    Hey Matt,

    Thanks for the video. What I attempted to do was recreate the AddUsersToGroup, except just have AddUserToGroup. I don't understand the People input that is with the given code engine, and I wanted it to just need a Person. This runs without error, but doesn't actually do what I want it to do, it doesn't appear to do anything when I have tested it out.

    const codeengine = require("codeengine");
    /**

    • Adds a user to a group
    • @param {Group} group - The group
    • @param {Person} person - The person
    • @returns {boolean} - true if the call was successful
      */

    function addusertogroup(group, person) {
    try {
    const url = /api/content/v2/groups/${group}/user;
    codeengine.sendRequest("put", url, person);

    return true;
    

    }catch (error) {
    throw new Error(error);
    }
    }

    module.exports = {
    addusertogroup
    };

  • MattTheGuru
    MattTheGuru Contributor
    Answer ✓
    Options

    I recreated the codeengine function that you are asking about.

    Loom example: https://www.loom.com/share/273ffd4a40324cb4af5ef9fe77844e31

    Exact code:

    ______________

    http://const codeengine = require("codeengine")

    async function addUsersToGroup(group, person) {
    try {
    const url = `/api/content/v2/groups/${group}/user`;
    await codeengine.sendRequest("put", url, [person]);

    return true;
    } catch (error) {
    throw new Error(error);
    }
    }

    module.exports.addUsersToGroup = addUsersToGroup;

    _________________

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.
    Please accept the answer if it solved your problem.

  • GregLaRose
    GregLaRose Member
    Options

    Thanks Matt, that did the trick. I appreciate your help!