pipedrive/client-nodejs

Using custom fields with the TypeScript version

tomtitherington opened this issue · 3 comments

Hello,

I'm using the latest TypeScript release candidate ^22.3.1-rc.4 to interact with the Pipedrive API. However, I've hit a blocker that I can't seem to solve.

I need to update custom fields on the Person entity via the API and was looking through the docs here. In the type UpdatePersonRequest there is no "custom_fields" property. I also couldn't see any support for custom fields in the DealsApi or LeadsApi.

Is sending custom fields via the TypeScript client supported? If so, how do I do that?

Thanks!

Hey @tomtitherington , thank you for reporting this, it seems to be an issue with the typescript types but the sdk/api itself should support updating custom fields if you pass their hash in the request.

to get the deal custom field hashes you can use the following

const dealFieldsApi = new DealFieldsApi(apiKeyConfig);
const fields = await dealFieldsApi.getDealFields();

and once you have the hash for the custom key you want to update you can send it with the following request

const dealsApi = new DealsApi(apiKeyConfig);
const data = await dealsApi.updateDeal({
	id: 4,
	UpdateDealRequest: {
		// @ts-ignore
		'e12f348118aed2ab3a243658e51fbf69a5cf630a': 'custom value',
		'f4b3d1d42afcc8b59850619f0ac3a07c892fbf62': 200,
	},
});

unfortunately you'll have to add a @ts-ignore on top of the custom field hash for now because the sdk doesn't allow unknown fields that aren't specified in the interface but we'll work on fixing that in a future release

I'll close this issue but feel free to re-open it if you still have any issues with it

Ah okay, thanks for getting back to me so quickly @youssef-saber-3 !