Skip to content

Instantly share code, notes, and snippets.

@Garconis
Last active March 7, 2023 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garconis/3e9f91ab097286c28ebf470729f76cff to your computer and use it in GitHub Desktop.
Save Garconis/3e9f91ab097286c28ebf470729f76cff to your computer and use it in GitHub Desktop.
Asana | Update custom fields of a task when using Zapier code
// 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