Hello there, I seem to be having problems setting a customFields format to currency with the API. I have tried two different methods to no avail.
The first method I have used is using node-fetch in my express server to hit the custom_fields route with a POST request.
const newField = {
data: {
currency_code: "EUR",
format: "currency",
name: "Price",
precision: 2,
resource_subtype: "number",
enabled: true,
workspace: `${process.env.workspaceGID}`,
},
};
try {
const response = await fetch(
`https://app.asana.com/api/1.0/custom_fields`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.PERSONAL_ACCESS_TOKEN}`,
},
body: JSON.stringify(newField),
}
);
const data = await response.json();
//console.log(data);
res.status(201).json(data);
} catch (err) {
console.error(err);
res.status(400).json(err);
}
And I have tried using the asana npm package to no avail.
const client = asana.Client.create().useAccessToken(
process.env.PERSONAL_ACCESS_TOKEN
);
client.customFields
.createCustomField({
currency_code: "EUR",
enabled: true,
format: "currency",
name: "Price",
precision: 2,
resource_subtype: "number",
workspace: `${process.env.workspaceGID}`,
})
.then((result) => {
console.log(result);
res.json(result);
})
.catch((err) => {
res.json(err);
});
});
In both situations I am successfully creating the custom_field of type number, but the format it is given is “Number” and I have to manually set it to the currency I want. Not sure if this is related but I also seem to have problems setting it’s format to “custom” and taking advantage of the custom_label and custom_label position options as well. Is there something basic I am missing here?