+ Start a Discussion
Jerry ClifftJerry Clifft 

Adding a LEFT to ApexPages.currentPage().getParameters().get('oppId');

I have a visualforce page and controller, part us which grabs "oppid" from the url and inserts it as part of the record.

a.Opportunity__c = ApexPages.currentPage().getParameters().get('oppId');
This works fine, if I have a URL such as:
salesforce.com/oppid=000013456789123

But sometimes, I get a URL such as:
salesforce.com/oppid=000013456789123?srPos=0

I would like to strip off everything after oppid=(first 15 chars). I was thinking about using something like LEFT,15 to do it. I have yet to get the formating right. Any suggestions?
Abhinav GuptaAbhinav Gupta
Not sure how this is happening by normal salesforce generated urls, you could try substring in apex i.e. 
if (oppId != null && oppId.length() > 15) {
            oppId = oppId.substring(0, 15);
        }