How to skip Null fields? PUT action to Activecampaign

Hi There,

Big noob over here. Trying to make a go of this and feel like a got a fighting chance…

I have created the trigger with the URL and sent data over successfully to ActiveCampaign using customfield params as highlighted in docs for updating a Deal using JSON: Authentication

It has been working great with a couple “customFieldIDs” that I used for testing. Worked every time. However, when I started to continue to build out the customFieldID’s and start pushing more data from the trigger. I get an error code when it stumbles across a NULL: “TypeErrorCannot read property ‘fullName’ of null”

Basically, if one field does not come back as expected with some data, it cancels the process and wont populate the remaining custom fields even though they have data. I thought this was the point of a PUT action… to only input fields that are updated and skip Nulls… but I must be missing something.

Example of when it wont send data: Sometimes I do not have the clients lawyers name yet, or email address etc… But I have the Realtors email and phone number. However if Lawyers data is NULL… the return does not provide the information, so the process stops and pushes error, and wont input remaining data like realtors name etc even if I have it.

Below is the code ive been using. Any help is sincerely appreciated. And you are also welcome to troll me for being an idiot as thats apparently what we do on the internet.

Code to sent data to ActiveCampaign:

// See the API docs: Authentication

if (!params.deal_id) {
throw new Error(“Must provide deal_id parameter.”);
}

const config = {
method: “put”,
url: ${auths.activecampaign.base_url}/api/3/deals/${params.deal_id},
headers: {
“Api-Token”: ${auths.activecampaign.api_key},
},
data: {
deal: {
title: params.title,
description: params.description,
account: params.account,
contact: params.contact,
value: params.value,
currency: params.currency,
group: params.group,
stage: params.stage,
owner: params.owner,
percent: params.percent,
status: params.status,
fields: [
{
customFieldId: 1,
fieldValue: params.dealCustomFieldForecastedCloseDate
},
{
customFieldId: 2,
fieldValue: params.dealCustomFieldDataLawyerFullName
},
{
customFieldId: 3,
fieldValue: params.dealCustomFieldDataLawyerEmail
},
{
customFieldId: 4,
fieldValue: params.dealCustomFieldDataRealtorsFullName
},
{
customFieldId: 5,
fieldValue: params.dealCustomFieldDataRealtorEmail
},
{
customFieldId: 8,
fieldValue: params.dealCustomFieldDataRealtorsPhoneNumber
},
{
customFieldId: 9,
fieldValue: params.dealCustomFieldLawyerPhone
},
{
customFieldId: 10,
fieldValue: params.dealCustomFieldLawyerFax
},
{
customFieldId: 11,
fieldValue: params.dealCustomFieldLawyerFirm
},
]
}
}
}
return await require("@pipedreamhq/platform").axios(this, config);

Hi There,

I am dealing with something similar. Did you ever figure out how to skip the null fields?

Thanks,
Chetan

I never did figure it out no. If you come up with anything please let me know!

@chetanmadaan @kylewils take a look at this post and let me know if that helps.

Thanks @dylburger. I’ll try the ? thing next time.

For the moment, I was working on a hubspot integration and if a field doesn’t have a value. It doesn’t have the object associated with the field. So, I used the typeof != undefined code as shown below and that seems to have done the trick.

var leadsource = '';
if(typeof steps.trigger.event.body.properties.leadsource !== "undefined"){
  leadsource = steps.trigger.event.body.properties.leadsource.value;
}