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
Josh GitogoJosh Gitogo 

Having trouble referencing Id code using VisualForce page

Hello everyone,
I have created a custom button on a custom object using a VF page. The function of this VF page is to create a screen from a specific record with two images on it, an add inventory image and a view inventory image. When the add inventory image is clicked it should lead to a separate screen which gives me the option to add inventory of that specific record, likewise when the view inventory button is clicked it should give me the option to view the inventory of that specific record. The problem is I don’t know how to reference each record’s specific 15-digit id number when the add and view inventory is clicked. As you can see in the images I attached below, when I click on the scan inventory screen button the add and view inventory screen contains the records 15-digit id number in the URL but when I click the view inventory button it loses the 15-digit number. If anyone knows how I can make sure the 15 digit id number comes up with every record please let me know. I have also attached the VF page that I used. I suspect the problem lies in the URL in the apex:output Link.  
<apex:page standardController="Sol_sence_Products__c">
   
    
    <apex:outputLink value="https://c.cs30.visual.force.com/apex/PracticeInventoryv6?scontrolCaching=">
<apex:image url="{!$Resource.View_Inventory_Button}" width="400" height="400"/>
    </apex:outputLink>  
    
    <apex:outputLink value="https://cs30.salesforce.com/a6D/e?CF00N3100000GottZ=">
<apex:image url="{!$Resource.Add_Inventory_Button}" width="400" height="400"/>
    </apex:outputLink>
    <a href="history.back();" onclick="history.back();">Back To Previous Screen</a>

</apex:page>

User-added imageUser-added imageUser-added image
Raj VakatiRaj Vakati

Hi , 
Can you please modify the code like shown here.
<apex:page standardController="Sol_sence_Products__c" extensions="TestEx">
   
    
    <apex:outputLink value="https://c.cs30.visual.force.com/apex/PracticeInventoryv6?id={!recId}">
<apex:image url="{!$Resource.View_Inventory_Button}" width="400" height="400"/>
    </apex:outputLink>  
    
    <apex:outputLink value="https://cs30.salesforce.com/{!recId}">
<apex:image url="{!$Resource.Add_Inventory_Button}" width="400" height="400"/>
    </apex:outputLink>
    <a href="history.back();" onclick="history.back();">Back To Previous Screen</a>

</apex:page>

public class TestEx{

public String recId{get;set;}
 public TestEx( ApexPages.StandardController stdController ){
        
              recId = stdController.getId();
   
   }
 }