I am building a Flow that takes a user through a wizard to create a custom contract object with detail objects that represent the products on that contract (stored as a junction object).  An issue I ran into is that Flow has a known limitation where if you use a Dynamic Choice (i.e. creating a dynamic set of checkboxes to choose Products from based on records from the Product object) it can only store the choices as a long semicolon delimited string in a variable; it cannot create detail objects based on your dynamic selection (even using a loop).

To get around this, I want the flow to just create the parent Contract, then I want an after insert Apex trigger to parse the field where the long string of semicolon separated Product Ids are stored.  The trigger would need to take the string and find each Id to store in a List.  Once I had the List made from the text field I could insert the Product detail records to the parent Contract.

I am very new to Apex, mostly just a point and click admin here.  I am struggling with how to use RIGHT and LEFT to loop through the string field.

trigger AddProductstoSOW on PS_Contract__c (after insert) {
        for(PS_Contract__c c:Trigger.new){
        List&lt;Id&gt; ProductsToInsert = new List&lt;Id&gt;;
        integer n = LEN(c.Initial_Services_Products__c);
      for(p=15,p&lt;n,p+17){
    //How to iterate through Initial_Products_Selected__c?
        thisId = LEFT(p);
        Id product = Id.valueOf(thisId);
        ProductsToInsert.add(product);
        }
    }
    insert ProductsToInsert;
}


Any help is very appreciated.


Question: The Google Time Zone API always returns Error status
Answer: Your $url is invalid. Try this:

$url = "https://maps.googleapis.com/maps/api/timezone/json?location=".$lat.",".$lng."&amp;timestamp=1419283200&amp;sensor=false";