mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
Manage custom properties on Hubspot deals
This commit is contained in:
parent
5288365104
commit
b1ba991367
|
@ -553,6 +553,25 @@ export class Hubspot implements INodeType {
|
||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Get all the deal properties to display them to user so that he can
|
||||||
|
// select them easily
|
||||||
|
async getDealCustomProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
const endpoint = '/properties/v2/deals/properties';
|
||||||
|
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
|
||||||
|
for (const property of properties) {
|
||||||
|
if (property.hubspotDefined === null) {
|
||||||
|
const propertyName = property.label;
|
||||||
|
const propertyId = property.name;
|
||||||
|
returnData.push({
|
||||||
|
name: propertyName,
|
||||||
|
value: propertyId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* FORM */
|
/* FORM */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -1801,6 +1820,17 @@ export class Hubspot implements INodeType {
|
||||||
value: additionalFields.pipeline as string,
|
value: additionalFields.pipeline as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (additionalFields.customPropertiesUi) {
|
||||||
|
const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
|
||||||
|
if (customProperties) {
|
||||||
|
for (const customProperty of customProperties) {
|
||||||
|
body.properties.push({
|
||||||
|
name: customProperty.property,
|
||||||
|
value: customProperty.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
body.associations = association;
|
body.associations = association;
|
||||||
const endpoint = '/deals/v1/deal';
|
const endpoint = '/deals/v1/deal';
|
||||||
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body);
|
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body);
|
||||||
|
@ -1846,6 +1876,17 @@ export class Hubspot implements INodeType {
|
||||||
value: updateFields.pipeline as string,
|
value: updateFields.pipeline as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (updateFields.customPropertiesUi) {
|
||||||
|
const customProperties = (updateFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
|
||||||
|
if (customProperties) {
|
||||||
|
for (const customProperty of customProperties) {
|
||||||
|
body.properties.push({
|
||||||
|
name: customProperty.property,
|
||||||
|
value: customProperty.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const endpoint = `/deals/v1/deal/${dealId}`;
|
const endpoint = `/deals/v1/deal/${dealId}`;
|
||||||
responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, body);
|
responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, body);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue