+ Start a Discussion

Split the field into 2 custom fields

hi to everyone,


i am converting the lead into account and contact using the vf page, but i am having a problem here,


i have 2 fields for street address in both accounts and contacts( line 1 and line 2).

when i convert the lead into accounts and contact i need to split street address field value into line 1 and line 2 in both accounts and contacts.


can someone please help me on this issue or some sample code.


thanks in advance.


How will you know how to parse out the Lead address into 2 fields? Based on a line break? If so, then you can do something like this

1) Write an after update trigger on Lead

2) If the Lead has been converted (i.e.  'IsConverted' is true), then split the Lead address field into 2 based on a Line Break (something like "String[] addresses = l.street.split('/n');")

3) Query the converted Account and Contact record (using the ConvertedContactId & ConvertedAccountId fields on the Lead object)

4) Update your 2 street address fields on those two objects based on the output of step 2.


Hope this gets you on your way.....


thanks for the reply,


i have 2 street address fields in accounts with 35 characters lenth on each field. so, requirement is that, from street address first 35 charactes need to fill in address line 1 and remaining characters need to fill in address line 2.


thanks for suggesting me the trigger, if you have sample code can you please post it here.

i am new to write triggers and test class for trigger again.




do we have any other options instead of trigger.


thanks again



With the kind of string manipulation that you need to do (and the fact that you only want this action to happen at Lead Convert), I think an Apex trigger is the only option. Unfortunately I don't have sample code for you, but you can get starrted with Apex by reading the developer guide here - http://www.salesforce.com/us/developer/docs/apexcode/index.htm. Best of luck!

Amal DevassiaAmal Devassia
how to split a field into 2 in lightning component????????