Copy property value action with cutom code output

Hello everyone!

I’m having trouble with the workflow action Copy property value used to update the deal amount.

The value that need to be used comes from a custom coded action.

The value is outputed by

callback

as usual like this:callback({ deal_amount: parseInt(amount)});

so the custom coded action output is like:

{"deal_amount":50}

So like I said I’m using this output to update the deal enrolled in the workflow with the Copy property value like this:

But it seems I cannot use those values, I only get this error:

I verified the output type, I used an integer, a float and a string and either way the Copy property value won’t update the deal Amount.

Can anyone help me with this?

Thanks!

If you are curious about the whole code:

const hubspot = require('@hubspot/api-client');
const axios = require('axios');
const hubspotClient = new hubspot.Client({accessToken: process.env.CustomCodeToken});
let amount = 0;

exports.main = async (event, callback) => {
 const headers = { "Authorization": "Bearer " + process.env.CustomCodeToken};
 const { data: { results: ass_contact } } = await axios.get(`https://api.hubapi.com/crm/v4/objects/deal/${event.object.objectId}/associations/contact`,{ headers: headers} );
 console.log(JSON.stringify(ass_contact, null, 2));
 // console.log(ass_contact[0].toObjectId);
 let query = { "filterGroups":[ { "filters":[ { "propertyName": "associations.contact", "operator": "EQ", "value": ass_contact[0].toObjectId } ] } ] };
 const deals = await hubspotClient.crm.deals.searchApi.doSearch(query);
 //console.log(JSON.stringify(deals, null, 2));
 if(deals.total > 0){
 deals.results.forEach(d => {
 if (d.properties.pipeline == "default") {
 amount = d.properties.amount;
 console.log(d.properties.amount);
 }
 });
 }

 callback({
 deal_amount: parseFloat(amount)
 });
}

Anyone has had the same issue? o(><;)oo

Hi @ACandian,

Thanks for reaching out to the Community!

I wanted to invite our subject matter experts to see if they have insight.

Hi @HFisher7, @louischausse, @DanielJeal - Have you encountered this error before? Do you have any advice for @ACandian?

Thank you!

Best,

Kristen

have you tried not parsing the output?

Hi, yes it was my first attempt. I started to forcibly parsing it when I noticed the error

Hi @ACandian,
You ommited to nest your output field in the outputFields object like this:

 callback({
 outputFields: {
 deal_amount: amount
 }
 });

Don’t forget to mark my reply as a solution if you are satisfied. If not, do not hesitate to ask me anything!

I really need some holiday.

Thanks :smiley: