Last active
March 7, 2023 22:23
-
-
Save Garconis/3e9f91ab097286c28ebf470729f76cff to your computer and use it in GitHub Desktop.
Asana | Update custom fields of a task when using Zapier code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is wrapped in an `async` function | |
// you can use await throughout the function | |
var adCampaign = inputData.adCampaign; // get the variable from the adCampaign | |
var adKeyword = inputData.adKeyword; // get the variable from the adKeyword | |
var taskID = inputData.taskID; // get the variable from the taskID | |
var finalAdKeyword = ""; | |
if ( (adKeyword == 'None') || (adKeyword == 'No Terms') || (adKeyword == '[channeldrilldown3]')) { | |
var finalAdKeyword = ""; | |
} | |
else { | |
var finalAdKeyword = adKeyword ; | |
} | |
let body = { | |
"data": { | |
"custom_fields": { | |
"235235623623": adCampaign, // Ad Campaign field and value | |
"723237233322": finalAdKeyword // Ad Keyword field and value | |
} | |
} | |
}; | |
// find the task based on the taskID | |
const res = await fetch('https://app.asana.com/api/1.0/tasks/' + taskID, { | |
method: 'PUT', | |
headers: { | |
'Authorization': 'Bearer 1/XXXXXXXXX' | |
}, | |
body: JSON.stringify(body) | |
}); | |
const data = await res.json(); | |
output = {data: data}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment