function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Helpdesk 3Helpdesk 3 

How to parse the street number out of the Street Address in Leads?

In our organization we use the LastName, FirstName and the street address number as the name of the opportunity. For example "Lastname, Firstname1234". Because this is not the default Opportunity name when you convert a lead into an Opportunity, my users need to type this every time they convert a lead. I created a custom convert button, and use a custom URL to load the LastName and the FirstName into the Opportunity Name field, but can anyone help me extract the street number from the street address and add it to the Opportunity Name? My custom URL looks like this:/lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}&noopptt={!Lead.LastName&", "&Lead.FirstName}
Best Answer chosen by Helpdesk 3
SantoshChitalkarSantoshChitalkar
Hi,

Use following code -

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var check = '{!Lead.Street}';

var res = check.split(" ");

window.open('/lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}&noopptt={!Lead.LastName&", "&Lead.FirstName}'+ res[0]);

Here is the settings screen shot for your reference -

User-added image

I hope, this will solve your problem. If this solves your problem then Mark this question and choose best answer.

Regards,
Santosh Chitalkar 

All Answers

SantoshChitalkarSantoshChitalkar
Hi

You can try using javascript. Follow the steps given below -
1) In javascript, get the Lead.Street and store it in string variable.
2) Use split method to get only street no and store it in variable say 'StreetNum'
3) use window.open(url)
like 
window.open(url)
/lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}&noopptt={!Lead.LastName&", "&Lead.FirstName&", "&StreetNum }

Mark this question as solved if this helps you and solve your problem

Regards,
Santosh Chitalkar
 
Helpdesk 3Helpdesk 3
Thank you Santosh for your quick reply. I am not a Javascript developer, I would very much appreciate it if you could help me with the code. Otherwise I will have to research your answer further and let you know how it worked out. Again, thank you very much.
SantoshChitalkarSantoshChitalkar
Hi,

Use following code -

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var check = '{!Lead.Street}';

var res = check.split(" ");

window.open('/lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}&noopptt={!Lead.LastName&", "&Lead.FirstName}'+ res[0]);

Here is the settings screen shot for your reference -

User-added image

I hope, this will solve your problem. If this solves your problem then Mark this question and choose best answer.

Regards,
Santosh Chitalkar 
This was selected as the best answer
Helpdesk 3Helpdesk 3
It works brilliantly. Thank you Santosh.