Hi,
I have the following code which looks up a field in Marketo and pulls through the content, but I have an issue I am trying to start a new row when a certain delimiter "Part" pops up within the content:
#if(!$lead.First_5_Lines_in_Basket__c.isEmpty())
#set($First_5_Lines_in_Basket__c = $lead.First_5_Lines_in_Basket__c)
#foreach($fivelines in $First_5_Lines_in_Basket__c.split("\n"))
$fivelines
#end
#end
The content pulling through is for example -
Part - 7984219, P2220 Oscilloscope Probe, Passive, 300 V Qty. - 11 Part - 2497216, ATREB215-XPRO - Expansion Board, AT86RF215 2.4GHz/Sub 1GHz Multi-Band Transceiver, IEEE 802.15.4/4g Compliant Qty. - 3
But would like it to split to next row when "Part" comes up within the content, so should look like as follows:
Part - 7984219, P2220 Oscilloscope Probe, Passive, 300 V Qty. - 11
Part - 2497216, ATREB215-XPRO - Expansion Board, AT86RF215 2.4GHz/Sub 1GHz Multi-Band Transceiver, IEEE 802.15.4/4g Compliant Qty. - 3
Any help would be appreciated.
Thanks
Solved! Go to Solution.
By "split to next row" I assume you mean "Insert an HTML line break"... do try to be as as clear as possible because there's no single definition of of row and line that covers both Text and HTML.
If that's indeed what you mean, then find the word "Part" and prepend it with <br>.
#if( !$lead.First_5_Lines_in_Basket__c.isEmpty() )
#set( $First_5_Lines_in_Basket__c = $lead.First_5_Lines_in_Basket__c )
#foreach( $fivelines in $First_5_Lines_in_Basket__c.split("\n") )
${fivelines.replaceAll("Part","<br>Part")}
#end
#end
By "split to next row" I assume you mean "Insert an HTML line break"... do try to be as as clear as possible because there's no single definition of of row and line that covers both Text and HTML.
If that's indeed what you mean, then find the word "Part" and prepend it with <br>.
#if( !$lead.First_5_Lines_in_Basket__c.isEmpty() )
#set( $First_5_Lines_in_Basket__c = $lead.First_5_Lines_in_Basket__c )
#foreach( $fivelines in $First_5_Lines_in_Basket__c.split("\n") )
${fivelines.replaceAll("Part","<br>Part")}
#end
#end
Thanks Sanford, that has helped.
Hi Sanford,
Thanks that did work but is there a way to split field $lead.First_5_Lines_in_Basket__c into 3 separate fields i.e. field 1, field 2 and field 3 which will allow me to place anywhere in an HTML table?
Something like below for each field
Field 1 = Part - 7984219,
Field 2 = P2220 Oscilloscope Probe, Passive, 300 V
Field 3 = Qty. - 11
At moment it pulls in as below:
Part - 7984219, P2220 Oscilloscope Probe, Passive, 300 V Qty. - 11
Thanks
#set( $lines = $First_5_Lines_in_Basket__c.split("\n") )
$lines is then an Array, and $lines[0], $lines[1], etc. are the individual lines.
Sorry Sanford, maybe I not explained correctly - the code already splits them to individual lines. I want to amend the code so I can separate each line where they maybe a comma:
Say this is one line: Part - 7984219, P2220 Oscilloscope Probe, Passive, 300 V Qty. - 11
Is it possible to use comma delimiter to spilt the above line? ie field 1 will only show "Part - 7984219" field 2 "P2220 Oscilloscope Probe, Passive, 300 V" and field 3 "Qty. - 11"
Thanks,
Is it possible to use comma delimiter to spilt the above line? ie field 1 will only show "Part - 7984219" field 2 "P2220 Oscilloscope Probe, Passive, 300 V" and field 3 "Qty. - 11"
Sure, why not? Same as any other delimiter.
Is there an example I can follow or maybe help update the above code?
Not clear how you're mixing-and-matching the logic here.
Splitting on a comma is simply
#set( $partsOfACommaDelimString = $lead.CommaDelimStringField.split(",") )