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
sathishsfdcsathishsfdc 

URLhack to prepopulate value to custom field

Hi,
I have a partner portal page which contains a phone number field which needs to be auto populated based on the URL..
Here s the code:
<apex:page standardcontroller="case" 
            extensions="ContactUs"
> 
   
    
    <apex:form id="formid">
        <apex:inputHidden value="{!selectedlanguageParam}" id="theHiddenInput"></apex:inputHidden>
        <apex:actionFunction name="languagefunction" action="{!languageSearch}" status="fetchStatus"  />                  
        <apex:pageBlock id="PbId" rendered="{!firstBlock}">
        
        <span style="color:red;"> <apex:pagemessages /> </span>
            
                <div>
                    <div class="headerText">
                        <h1 class="h1Text">{Case}</h1>
                    </div> 
                </div>
            
                    
                <apex:outputpanel id="firstBlock1">
                    <div width="90%" cellspacing="10" cellpadding="5">
                        <div>
                            <apex:outputPanel rendered="{!isReqPhNo2}">
                                <b class="textlabel">{!$Label.Phone_Number}</b>
                            </apex:outputPanel>
                            <apex:outputPanel rendered="{!isReqPhNo}">
                                <b class="textlabel">{!$Label.Phone_Number}<span class="required">*</span></b>
                            </apex:outputPanel>
                        </div>
                        <div class="test1"> 
                            <apex:inputText id="Number" value="{!phoneNumber}" styleclass="txtbx" maxlength="35"/>                          
                        </div>                        
                    </div> 
                </apex:outputpanel>
                      
        
</apex:page>

public class ContactUs 
{
public ContactUs(ApexPages.StandardController stdController) { 
        csccustom=new Submit_Acase__c();
    }
	
	public PageReference languageSearch(){
        try{
        
        currentRequestURL = URL.getCurrentRequestUrl().toExternalForm();
          system.debug('selectedlanguageParam===='+selectedlanguageParam);
          PageReference p;
          system.debug('currentRequestURL==='+currentRequestURL);
          if(selectedlanguageParam=='Japanese'
          {
                if(currentRequestURL.contains('l=')) currentRequestURL = currentRequestURL.subString(0,currentRequestURL.length()-8);
                p = new PageReference(currentRequestURL+'?l=zh_KN
  
          }
          else
          {
                if(currentRequestURL.contains('l=')) currentRequestURL = currentRequestURL.subString(0,currentRequestURL.length()-8);
                //p = new PageReference(currentRequestURL+'?l=en_US&pageid:formid:PbId:Number=1');//--i was trying something like this
                p = new PageReference(currentRequestURL+'?l=en_US');
                  
  
          }
        
          return p;
          }catch(Exception ex){
        }
        return null;
     }

Also i have attached the screenshot.
User-added image


I was trying something like this:
http://writeforce.blogspot.in/2013/01/prepopulating-fields-using-url-hacking.html
Please advise
shashi lad 4shashi lad 4
The best way that I've found to get the ID of the field that you want populated is by navigating to the field in setup. For example, if I want to prepopulate ObjectDetail_c.TextField_c, I would go to Setup => Create => Objects => ObjectDetail => TextField, which takes me to to the URL

Once you know the id of the field you want to populate, you use <fieldId>=TextValue&_lkid=<recordId>. Using the example in the link, if the fieldId is CF00NA0000005JzZX, then the parameter is CF00NA0000005JzZX=98729921111 you need to pass in URL.

Hope this helps
thanks
shashi