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

Using field ID to set field

I have a VF page where the user selects an item and when they click it, I call another page. I want to pass a value to the 2nd page.  I set the Id of the field on the second page to the value of what hey selcted.  It works great.  But, now I want to promote it to the dev org and the Id of the field will be different.  I tried setting the name of the field but that didn't work. How do I develop in the Sandbox and then promote the code without having to change the Ids?


Also, the field I am passing to is a Lookup.  I would like to pass the Id rather than the name of the item in the lookup but it only works when I pass the name.  Is there a different field I should pass the Id to?






Could you post some of your code please? Just so we can have a look at the method you're employing.





Sure.  I am trying to duplicate enhanced lookup since it is not available to a portal user.  So I give them three picklists and when they click search I present the list with the ability to click on the one they want which passes that value to a standard pag(not VF). CF00N40000001yA32 is the lookup field that will only take the value not the Id. 


<apex:page controller="labelCatalogController" id="labelCatalogSearchPage">
  <apex:form >
    <apex:pageBlock >

      <apex:pageBlockButtons >
        <apex:commandButton action="{!search}" value="Search"></apex:commandButton>
        <apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton>

      <apex:pageBlockSection columns="1">
        <apex:inputField value="{!catalog.Material__c}"></apex:inputField>
        <apex:inputField value="{!catalog.Material_Sub_type__c}"></apex:inputField>
        <apex:inputField value="{!catalog.Imprint_Process__c}"></apex:inputField>
      <apex:pageBlockSection columns="1">
        <apex:pageBlockTable value="{!searchResults}" var="c" rendered="{!NOT(ISNULL(searchResults))}">
          <apex:column headervalue="Label Number">
            <apex:commandLink action="/a0R/e?CF00N40000001yA32={!c.URLName__c}" target="_self">{!c.Name}</apex:commandLink>
          <apex:column value="{!c.Material__c}"/>
          <apex:column value="{!c.Material_Sub_type__c}"/>
          <apex:column value="{!c.Imprint_Process__c}"/>
          <apex:column value="{!c.Attachment__c}"/>
          <apex:column value="{!c.Label_Size__c}"/>