How can we help?

Find User for Zappier

Comments

4 comments

  • Avatar
    Juan Jimenez

    Hi, just wondering if would it be possible to add a few more fields to the Zapier integration, noticed that would be extremely useful if the Zapier template can have also: Assignee (Find User), Estimated Hours and Dependency

  • Avatar
    Benjamin Hille

    To be honest the Zapier integration is a bit weak as the "interesting" features are not implemented. I ended creating my own Zapier code for the bit I need. For instance you can retrieve a user by email using the following:

    /**
    * FindUserIDFromEmail.js
    */
    const authorizationString = 'PUT_YOUR_AUTHORIZATION_STRING_HERE';
    const epUrl = 'https://YOUROMPANY.go.easyprojects.net/rest/v1/users';
    const headers = {
    'Authorization': 'Basic ' + authorizationString,
    'Content-Type': 'application/json'
    };

    fetch(epUrl, {
    method: 'GET',
    headers : headers
    }).then(function(response) {
    return response.json();
    }).then(function(json) {
    json.forEach(function(user){
    if ( user.EMail === inputData.user_email ) {
    callback(null, [{user_id: user.UserID}])
    }
    })
    callback(null, [])
    }).catch(function(error){
    callback(error)
    })

  • Avatar
    Juan Jimenez

    This looks awesome, thanks for the comment Benjamin.

    We have a Zapier integration in place to set up a few tasks in Easy Projects based on Jira submissions, everything is working, however, after each submission, we need to add this missing information manually: assignee, Estimated Hours and Dependency (to the previous task created)

    If you know, can you point me to the right direction to complete these tasks automatically?

    For the Easy Projects folks, can these fields be added to the template in Zapier?

    Thanks

  • Avatar
    Benjamin Hille

    assignees are a bit of a nightmare as they are linked to project members so I have hard coded mine as I only have 6 users, then attach the assignees using the API again. 

     
    See below:
    /**
     * AddAssigneeToTask.js
     */
    // HERE USE THE API BROWSER TO FIND THE MATCH BETWEEN THE PROJECT MEMBER ID AND USER ID 
    // YOU COULD REPLACE THIS WITH A PREVIOUS STEP THAT USES API TO SEARCH THE PROJECT MEMBER
    const caseProjectMemberIds = { 
    1: 2177468,
    2: 2177469,
    3: 2177470,
    4: 2177471,
    5: 2177472,
    6: 2177473
    };
     
    const taskAssignee = {
    TaskID: inputData.case_id,
    UserID: inputData.user_id,
    ProjectMemberID: caseProjectMemberIds[inputData.user_id]
    };
     
    const authorizationString = 'XXXX';
    const headers = {
      'Authorization': 'Basic ' +  authorizationString,
      'Content-Type': 'application/json'
    };
     
    fetch(epUrl, {
    method: 'POST',
    headers : headers,
    body: JSON.stringify(taskAssignee)
    }).then(function(response) {
    return response.json();
    }).then(function(json) {
    callback(null, json)
    }).catch(function(error){
    callback(error)
    })
     
    For EStimated hours and dependency you should be able to use the same technique but use the activity API https://XXX.go.easyprojects.net/rest/v1/activities/{TaskID} with a PUT.

Please sign in to leave a comment.