Gavan Walker

How to Optimize Multiple Rest calls in PHP Loop *RESOLVED*

Discussion created by Gavan Walker on Jan 9, 2018
Latest reply on Jan 27, 2018 by Karel Čech

Hey Everyone,

 

I've moved to sugar on demand for my work and a compromise I've had to make for this move is to re-write a system to use the REST API rather than direct mysql calls.

 

My program makes numerous API calls which makes it quite slow, I know I can use things like the bulk feature but I am unsure how to get the ID of a linked record to use without making the call to the related field to begin with.

 

I essentially have a tool which pulls out meetings which fall under a certain date and then pull the related contact information out too.

 

My first call is easy and fast and that is passing a filter to meetings with my date paramaters

/Meetings/filter

 

Now this is the part where things get really slow.

I Loop through my results and to get the information of the related contact, I run the below api request

 

/Meetings/".$sugar_meeting->id."/link/contacts

 

You can see this is quite cumbersome and timely experience, I have had a read into it and the bulk command would be ideal, the problem is, there are no fields I seem to be able to pull from the meeting through the api to get the ID of the related contact or invitee.

 

If I can get he id of the invitee I can cross reference it against internal staff id and work out the contact id and then run my bulk call.. adding in my filter invitees ect does not retrieve that data.

 

Is there a way to get the id of the contact through my initial filter command? though the invitee list?

 

 

EDIT:

Strange, adding the word invitee to the fields in the filter for meetings works now... previously it didn't... more than likely an issue my end, it is really good as the invitee array will let me know if the user is a Contact or a User so I don't need to cross check

 

Here is a link with a working example of the bulk feature if anyone else is interested

https://www.upcurvecloud.com/blog/sugarcrm/working-with-large-sets-of-records-in-sugar-bulk-api

 

Second Edit

After implementing the above, the process now is like 90% quicker... great!

 

Thanks guys

Outcomes