⚙ Operations Hub

SteveHTM
Top colaborador(a) | Parceiro
Top colaborador(a) | Parceiro

Custom coded workflows using custom objects

resolver

Community - hope you can help. I'm working on a complex workflow that uses at least one custom coded workflow step. The issue I'm running into is that I need to search/filter/sort custom objects (rather than contacts/companies etc) in the coded workflow step and I don't understand how to use the Javascript APIs to access these objects.

 

Is there a document I've failed to find or a code example/snippet somewhere that can help?

 

Regards

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Avaliação positiva
1 Solução aceita
nikodev
Solução
Top colaborador(a) | Parceiro Elite
Top colaborador(a) | Parceiro Elite

Custom coded workflows using custom objects

resolver

Hey there @SteveHTM

There are a few ways to make API calls related to custom objects. The most important part of this is identifying what's called the objectTypeId of the custom object. The easiest way to identify this id in the CRM is by going to the index page of the custom object you're looking to query, and take a look at the url.


I've attached a screenshot of an example. Note the part highlighted at the top. The object type id will always be in this portion of the url on the index page of the custom object. It will always be in the format "2-" followed by...I think it's 6 or 7 digits. 

 

Another option would be to retrieve all schemas in the portal and find the ID based on the label of the custom object, or the schema name - "Hospital" for example, if we were looking at the object in the screenshot. This, in most cases, won't be necessary. See the "Get all schemas" endpoint in the docs HERE

You won't be able to use the hubspot api client in the same fashion as you would if you were querying the standard objects, which would allow you to use simple dot notation to access the appropriate endpoints. 

Below is an example search api request using a custom object

		let courseSearchObj = {
			filterGroups: [
				{
					filters: [
						{
							value: `${enrollmentInfo.course_id}`,
							propertyName: "thinkific_course_id",
							operator: "EQ"
						}
					]
				}
			],
			properties: ["id", "thinkific_course_id", "name"],
			limit: 1,
			after: 0
		};

		let courseSearchRes = await hubspotClient.apiRequest({
			method: "POST",
			path: `/crm/v3/objects/2-1877015/search`,
			headers: {
				accept: "application/json",
				"content-type": "application/json"
			},
			body: courseSearchObj
		});


The docs linked earlier on in this post will give more details on searching via API when working with custom objects. Make sure to navigate to the "Objects" tab. 

Hopefully this helps. 

A8 Labs

Exibir solução no post original

0 Avaliação positiva
3 Respostas 3
nikodev
Solução
Top colaborador(a) | Parceiro Elite
Top colaborador(a) | Parceiro Elite

Custom coded workflows using custom objects

resolver

Hey there @SteveHTM

There are a few ways to make API calls related to custom objects. The most important part of this is identifying what's called the objectTypeId of the custom object. The easiest way to identify this id in the CRM is by going to the index page of the custom object you're looking to query, and take a look at the url.


I've attached a screenshot of an example. Note the part highlighted at the top. The object type id will always be in this portion of the url on the index page of the custom object. It will always be in the format "2-" followed by...I think it's 6 or 7 digits. 

 

Another option would be to retrieve all schemas in the portal and find the ID based on the label of the custom object, or the schema name - "Hospital" for example, if we were looking at the object in the screenshot. This, in most cases, won't be necessary. See the "Get all schemas" endpoint in the docs HERE

You won't be able to use the hubspot api client in the same fashion as you would if you were querying the standard objects, which would allow you to use simple dot notation to access the appropriate endpoints. 

Below is an example search api request using a custom object

		let courseSearchObj = {
			filterGroups: [
				{
					filters: [
						{
							value: `${enrollmentInfo.course_id}`,
							propertyName: "thinkific_course_id",
							operator: "EQ"
						}
					]
				}
			],
			properties: ["id", "thinkific_course_id", "name"],
			limit: 1,
			after: 0
		};

		let courseSearchRes = await hubspotClient.apiRequest({
			method: "POST",
			path: `/crm/v3/objects/2-1877015/search`,
			headers: {
				accept: "application/json",
				"content-type": "application/json"
			},
			body: courseSearchObj
		});


The docs linked earlier on in this post will give more details on searching via API when working with custom objects. Make sure to navigate to the "Objects" tab. 

Hopefully this helps. 

A8 Labs

0 Avaliação positiva
SteveHTM
Top colaborador(a) | Parceiro
Top colaborador(a) | Parceiro

Custom coded workflows using custom objects

resolver

Thank you @nikodev - this is helpful material that really should be added to the API documentation.

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Avaliação positiva
PamCotton
Gerente da Comunidade
Gerente da Comunidade

Custom coded workflows using custom objects

resolver

Hello @SteveHTM , I would like to invite our top experts to share their ideas @LMartinez7 @bryce-corey any recommendations to @SteveHTM matter?

 

Thank you,

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Avaliação positiva