+ Start a Discussion
rDr4g0nrDr4g0n 

Id value {!Contract.Id} is not valid for the Contract standard controller

I have run into this problem in a few places with Contract. It's pretty obvious that Contract has an Id, as it is visible in the URL for the individual contract.

 

I am creating a custom button and I need to use the Id to load up the correct Contract in my visualforce page. The page works fine if I manually paste in the Id. The button is set to "URL" as the content source, and the following code is used: 

 

 

apex/PDAdContract?id={!Contract.Id}

So, why would it say that Contract has no Id? How can I get the Id?

 

THanks! 

 

Best Answer chosen by Admin (Salesforce Developers) 
prageethprageeth

Hello rDr;

Add a slash at the begining of your URL as below.

 

/apex/PDAdContract?id={!Contract.Id}

 

All Answers

bmabma

Try selecting Visualforce Page as the content source, instead of "URL".

 

Using "URL" as content source requires static value. It will not evaluate any expression, in this case {!contract.id}.

 

billy

prageethprageeth

Hello rDr;

Add a slash at the begining of your URL as below.

 

/apex/PDAdContract?id={!Contract.Id}

 

This was selected as the best answer
Pradeep_NavatarPradeep_Navatar

Tryout the following syntax :

 

/apex/PDAdContract?id={!Contract.Id}.

 

This will work to open a visual force page along with id on the click of detail button.

 

Hope this helps.