H Rashid
H Rashid

Reputation: 11

Split strong to separate fields - Velocity code Marketo Java

I have some working code:

#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", -1) )
${fivelines.replaceAll("Part","<br><br>Part")}
#end
#end

Which outputs puts the following:

Part - 7984219, P2220 Oscilloscope Probe, Passive, 300 V Qty. - 11

Is it possible to split the First_5_Lines_in_Basket__c field to 3 separate field, such as

Field 1 = Part - 7984219
Field 2 = P2220 Oscilloscope Probe, Passive, 300 V
Field 3 = Qty. - 11***

This will allow me to place field anywhere within an HTML table.

Thanks,

Upvotes: 1

Views: 95

Answers (1)

Casey Grimes
Casey Grimes

Reputation: 127

You actually already have most of your answer in your code—in this case, because you're using $fivelines.replaceall, there's no reason you couldn't use this with a little regex to split your string into individual lines, then add those each to an array that you'd output as a table. The real difficulty comes with $fivelines itself, as it's not marked up in a way that makes it straightforward to split out your field values. If you can alter that somehow (whether that's adding a separator character, structuring the data in some way, etc.) that will go farther and make whatever solution you come up with less fragile.

Upvotes: 0

Related Questions