For Each Loop only returns 1st result of List, not the whole list?
I have a custom function that collects event data from Google calendar using invokeURL. I want to create meetings in CRM from this URL response.
The invokeURL response contains over 100 records and works perfectly (code line 2). Then I'm using a For Each loop to create meetings for each record in the URL response.
Meeting creation using createRecords works perfectly EXCEPT it only creates 1 event from the 1st entry in the response. Code below.
I verified that the loop iterates with an info statement (line 5 "info evnts"), which returns all the expected results. However only 1 creation takes place and only 1 "Create Event" info statement displays (Last line, 14)
- info Googleresponse;
- for each evnt in Googleresponse
- {
- info evnt;
- mp = {
- "Event_Title":(evnt.getJSON("summary"),
- "Start_DateTime":evnt.getJSON("start").getJSON("dateTime"),
- "End_DateTime": evnt.getJSON("end").getJSON("dateTime"),
- };
- Create_GOOGL_Event = zoho.crm.createRecord("Events", mp);
- info Create_GOOGL_Event;
- }
What is going on and how do I fix it?