Skip to content

Instantly share code, notes, and snippets.

@jonurry
Created April 29, 2020 15:57
Show Gist options
  • Save jonurry/80191a6a9fcd1c69e4e38686fc47d904 to your computer and use it in GitHub Desktop.
Save jonurry/80191a6a9fcd1c69e4e38686fc47d904 to your computer and use it in GitHub Desktop.
async input => {
const { access_token, destination_project_id, source_project_id } = input;
let copiedFieldCount = 0;
// Get the source project
const sourceProject = await falafel.asana.getProject({
access_token,
project_id: source_project_id,
});
// extract the custom field settings
const customFieldSettings = _.get(
sourceProject,
'data.custom_field_settings',
[],
);
// add each custom field setting to the destination project
for (let setting of customFieldSettings) {
await falafel.asana.addCustomFieldToProject({
access_token,
project_id: destination_project_id,
custom_field_id: setting.custom_field.gid,
is_important: setting.is_important,
});
copiedFieldCount++;
}
return {
success: true,
fieldsCopied: copiedFieldCount,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment