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
Gaurav AgnihotriGaurav Agnihotri 

3 Extra Characters after Quote Id when button opens a VF page

Gurus,
I never came across such an issue. I am opening a visual force page by a button and passing Quote Id. This page has three 4 buttons that open a URL within salesforce. The issue is that the Quote Id has an extra 3 characters at the end of Quote Id and it does not open the right URL.
Here is the class:
public class QuoteToExcelClass {

public String Page {get; set;}
    public String OpenPageURL {get; set;}
    public Id sQuoteId {get; set;}
    
    public void QuoteToExcelClass(ApexPages.StandardController controller )
    {

    }
    
        
    
    public void QuoteToExcelClass()
    {
        Page = '' ;
        OpenPageURL = '' ;
    }
    
    public void redirect()
    {
        sQuoteId= ApexPages.currentpage().getparameters().get('id');
        if(Page == 'Dealer')
        {
            OpenPageURL = 'https://pelcosales.schneider-electric.com/Salesforce/ExportQuote/Index/'+sQuoteId+'/Dealer';
        }
       if(Page == 'Standard')
        {
            OpenPageURL = 'https://pelcosales.schneider-electric.com/Salesforce/ExportQuote/Index/'+sQuoteId+'/Standard';
        }
       if(Page == 'Discounted')
        {
            OpenPageURL = 'https://pelcosales.schneider-electric.com/Salesforce/ExportQuote/Index/'+sQuoteId+'/Dealer';
        }
       if(Page == 'MSRP')
        {
            OpenPageURL = 'https://pelcosales.schneider-electric.com/Salesforce/ExportQuote/Index/'+sQuoteId+'/Dealer';
        }
        
    }    


}

Here is Page:
<apex:page id="pg" standardController="Quote" extensions="QuoteToExcelClass">

<apex:form >

<apex:actionFunction action="{!redirect}" name="OpenPage" reRender="pb,theIframe">
    <apex:param assignTo="{!Page}" value="" name="param1"/>
</apex:actionFunction>


    <apex:pageBlock id="pb">

        <apex:pageBlockButtons >
            <apex:commandButton value="Discounted" onclick="OpenPage('Discounted'); return false;"/>
            <apex:commandButton value="MSRP" onclick="OpenPage('MSRP'); return false;"/>
            <apex:commandButton value="Standard" onclick="OpenPage('Standard'); return false;"/>
            <apex:commandButton value="Dealer" onclick="OpenPage('Dealer'); return false;"/>
        </apex:pageBlockButtons>
        <apex:outputText style="font-style:italic" value=" this is just a test value will not be in Production: {!OpenPageURL}">
            </apex:outputText>
        <apex:iframe id="theIframe" src="{!OpenPageURL}" scrolling="true"/>

    </apex:pageBlock>


</apex:form>
</apex:page>

User-added image

As you can see there are 3 extra characters "CAK" after Quote Id  

Regards, 
Gaurav
Best Answer chosen by Gaurav Agnihotri
pconpcon
What you are seeing is the difference between a 15 and 18 character Id.  You can read more about them here [1] but the gist is that the 15 character ids are older and are case sensitive.  The 18 character ids are newer and are not case sensitive.  Both will work (assuming you maintain case) for any Id reference.

If you require that the Id be 15 characters long, you can always trim it
 
Id myId = '0Q0g0000000F6QwCAK';
Id shortId = myId.left(15);

[1] https://help.salesforce.com/apex/HTViewSolution?id=000004383&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000004383&language=en_US)

All Answers

pconpcon
What you are seeing is the difference between a 15 and 18 character Id.  You can read more about them here [1] but the gist is that the 15 character ids are older and are case sensitive.  The 18 character ids are newer and are not case sensitive.  Both will work (assuming you maintain case) for any Id reference.

If you require that the Id be 15 characters long, you can always trim it
 
Id myId = '0Q0g0000000F6QwCAK';
Id shortId = myId.left(15);

[1] https://help.salesforce.com/apex/HTViewSolution?id=000004383&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000004383&language=en_US)
This was selected as the best answer
Gaurav AgnihotriGaurav Agnihotri
Thanks pcon for your help and explaination.