[SalesForce] Id value is not valid for the Document standard controller

I am trying to upload a csv file and creating object(code) using the contents of file.I have created a custom link on detail page of my custom object(line) like this(on click javascript) –
window.top.location.href='/apex/Zip_Codes?Id={!Line__c.Id}'

I have also created class and a vf page to load the csv file. In vf page m using standard controller as Document and extension as my controller class.

But on clicking the custom link currently i am getting the below error-

Id value a0Sn00000005v0k is not valid for the Document standard
controller

As per my observation this error is coming as it is passing 15 digit id to Document object and it is expecting a 18 digit id. What is the solution for this. Please help.thanks in advance.

Best Answer

I think this is a syntax issue. Because of the standard controller the passed ID should be of type Document. In your case it is of type Line__c. Try to rename the ID parameter to something else, for example lineId.

Read this article: Building Visualforce Pages Using Standard Controllers. Especially the following:

The standard controller requires record context that can be provided by including a URL parameter named ‘id’ and assigned with a valid 15- or 18-digit record ID. The record specified by the ID must match the sObject type associated with the StandardController on the page, or an error will be thrown when the page attempts to render.

So you need to pass an Document ID instead of the Line__c ID

In other words if using standard controller the ID parameter is reserved. You have to pass your custom values using other parameter names.

Related Topic