APIs & Integrations

NehaMehta
Member

Associations between custom object records and company

SOLVE
Hi Everyone,I'm currently working on a usecase wherein I need to associate custom object records with their respective companies. In order to achieve this, I have created a workflow with Custom Code action added in it. I need to execute this workflow on daily basis as new records of custom object are pushed daily.
There is a field org_id , association is done on the basis of org_id .If org_id of a custom object record matches with a companies org_id then association between the 2 records take place.
Custom code action is responsible for following actions:
  1. Get a list of all companies(around 23k+)
  2. Loop over the custom object records to find matching org_ids
  3. Finally associate all records with matching org_id
After scheduling the workflow to execute daily , I'm facing following issue:
1. The custom code does not execute fully , it shows "error" in the logs stating "Task timed out after 20.03 seconds"
Note: If I test the custom code action on my sandbox account , it works perfectly fine .(It has less data as compared to my production account).
Any leads on resolving these issues would be very helpful.  Thank you in advance.
0 Upvotes
1 Accepted solution
coldrickjack
Solution
Top Contributor

Associations between custom object records and company

SOLVE

Hey @NehaMehta,

 

Custom coded workflow actions  will fail if one of two things occurs:

 

  1. They consume 128MB of memory
  2. They exceed 20 seconds of runtime

This is documented here under "limits". As per the error coming back it's the 20 second runtime being exceeded and I think it's to do with the amount of data you are looping through (23K companies). The only way to fix this would be to streamline the code and make it more efficient.

 

A suggestion might be to simply using the CRM Search API to find companies in the CRM matching the custom object org_id. This would only return companies matching and remove the need to loop through 23,000+ records which I feel is creating this issue. You could then associate accordingly.

 

I hope this helps!

 

 

View solution in original post

0 Upvotes
2 Replies 2
DStaat
Participant

Associations between custom object records and company

SOLVE

Hey @NehaMehta,

I'm a little late to the party but have you heard of 
Associ8? It lets you automatically create associations between objects based on parameters you set. There's some documentation showing how it works here.

Let me know if you have any questions! I'd be happy to talk with you about it in more detail.

Best,

-David Staat

0 Upvotes
coldrickjack
Solution
Top Contributor

Associations between custom object records and company

SOLVE

Hey @NehaMehta,

 

Custom coded workflow actions  will fail if one of two things occurs:

 

  1. They consume 128MB of memory
  2. They exceed 20 seconds of runtime

This is documented here under "limits". As per the error coming back it's the 20 second runtime being exceeded and I think it's to do with the amount of data you are looping through (23K companies). The only way to fix this would be to streamline the code and make it more efficient.

 

A suggestion might be to simply using the CRM Search API to find companies in the CRM matching the custom object org_id. This would only return companies matching and remove the need to loop through 23,000+ records which I feel is creating this issue. You could then associate accordingly.

 

I hope this helps!

 

 

0 Upvotes