Help decipher the code - error and I'm stumped
Hi All  I am hoping that someone can help me decipher what I am doing wrong here as I'm pulling my hair out :) .... ok background ... I have an app with two simple fields that are populated with the subject and body of an email that comes in from an external system -  CallRail.... that provides summary details of a call complete with hyperlinks.  Image of the email data as shown in Podio in one app  is below: Now...  Within Globiflow I have created two variables  'Phone' and 'Recording' within a flow that creates a new seller record (different app) and should pass over the key information into the correct fields within the seller record ... namely the Phone number and the Recording (listen to recording hyperlink) the code I am using is shown below : The recording variable works fine ! But the phone number is not parsed and injected into the new seller record.  (note that the phone field in the seller app is a phone field where i think I might be where i am going wrong When I type the phone code , globi-flow states 'Empty'  yet the recording variable shows what it is capturing    Could someone please decipher my error as I am at a loss ....  Would also be interested to learn how I might create the variable code that captures the 'Call back' hyperlink but first things first    Any help greatly appreciated  Thanks Lawrence

  • Hello Rainer -  yes 5 months later I return with a slight query on this topic ...!!!   - its been working very well - albeit in limited capacity - hasn't been rolled out yet.... you kindly helped me out with above and steered me away from Regex for which I am very grateful ...  the extraction of the digits after the text 'number' from this  into a variable using the 'preg_match_gf' code below  in order to create a new item and populate the phone number field .... However, slight problem ... just noticed that if the number comes in with a "+" before the number , like : the number does not get captured.  this only happens when inbound calls communicted by callrail in the above way carry a '+' before the digits - all other time - just digits and the preg_match code captures it just nicely! I am not sure whether that is the variable code that is not capturing the number because of the '+'  or whether its because the destination field that GF tries to populate is a phone number field and doesnt like the '+'   Would really appreciate your expert eyes giving me a steer over best way to resolve   Many thanks Lawrence
  • Hi Lawrence, substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")) get's a substring of the field's total text beginning with the string "Number Name: " till the end of the text (= alerts/567486): explode(" ", string) splits the remaining text after each " " and returns an array with elements. First element is "Number", second is ".Name:", third is "Probate". Cause the counting of the elements starts at 0, [0] = "Number" and [2] = "Probate".  If you know that there is always a string with 3 words behind "Number Name: " you can do:explode(" ", substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")))[2]." ".explode(" ", substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")))[3]." ".explode(" ", substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")))[4]That's a bit cumbersome. In this case I would explode the substring by something which is directly after "Number Name: Probate Campaign #1" , either a hidden html tag (it's maybe </p> or <br />) or by the word "Tracking". But at first I would start the substring after "Number Name: ". The length of the string "Number Name: " is 13 substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")+13) returns the remaining text beginning with "Probate". explode("Tracking", substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")+13))[0] gets what you want (including the html tag between #1 and Tracking)strip_tags(explode("Tracking", substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")+13))[0]) should remove this tag. Rainer
  • Hi Rainer..... quick one ... just so I understand how to use the explode command  if i wanted to extract all the words after 'Number Name':     e.g.   Number Name: Probate Campaign #1 I would use  explode(" ", substr([(Call record) Notes],strpos([(Call record) Notes],"Number Name: ")))[2]   Which returns 'Probate'   but how do I get the remaining ? Once again, thanks for your help!!    
  • You are a genius Rainer.... thank you so much for taking the time out to provide such a comprehensive reply .... taken your advice and dropped Regex ... too complicated .... now works a treat !!
  • Hello Lawrence, you have to escape the hyphen in the phone regex (like you escape the brackets) \\- or you have to to out it right behind the 9 (then you don't have to escape it). For the use of hyphens in a regex you have to follow some rules (you can google it).  Btw: you don't need all the special characters (-() \\s = blank) in the regex you Callrail seems to send digits only. [0-9] would do it.   Regex can really be complicated. I only use them if there's no other option to get the wanted string/data, most time you'll get the result with substr() too. One (out of many) alternatives: explode(" ", substr([(Call record) Notes],strpos([(Call record) Notes],"from ")))[1] substr([(Call record) Notes],strpos([(Call record) Notes],"from ")) - gets the substring starting at the position of the string "from ",explode (" ") splits the remaining substring by " " and returns an array, [1] gets the second element in this array.  Don't rely on the field preview. Even if it shows empty, the calculation in the var can be correct, use the Simulate Variable function at the bottom of the flow template. But in your case (unescaped hyphen) the field indeed returns "" (= nothing). To get the Call Back link: preg_match_gf("/(https:[^\\s]+)/ism",explode("call back:",[(Call record) Notes])[1],1)  or w/o regex explode("<hr",explode("Call Back:",[(Call record) Notes])[1])[0] Which string you can use for the explode depends on which (hidden) html tags are in the field around the link. You can see it either with a browser inspect or just click Simulate Variable in GF and then look into the variable where [(Call record) Notes] is in. Rainerrg@delos-consulting.com
This question is closed.