I am getting an invalid ID error in my VF page on the below code and I don't understand what I am missing.
In my controller's constructor I am running the below code:
system.debug('SystemChangeRequest View/Edit PAGE demand ID: '+sObjectRFC.Demand__c);
system.debug('SystemChangeRequest View/Edit PAGE GET DEMAND QRY');
if (sObjectRFC.Status__c=='Converted' && sObjectRFC.Demand__c !=''){
system.debug('SystemChangeRequest View/Edit PAGE GET DEMAND inside IF block');
demandName=[Select Id, Name from apm2__Demand__c where Id =: sObjectRFC.Demand__c].Name;
system.debug('SystemChangeRequest View/Edit PAGE demand ID: '+sObjectRFC.Demand__c);
//demandName='TEST DEMAND';
}
in the developer console logs I can see that sObjectRFC.Demand__c
= 'a0U8E000002tZwj'
and I can access that record on the Demand object through salesforce with the url https://domain.salesforce.com/a0U8E000002tZwj
Of course I can show the Id in my VF page with no problems, but I want to show the record identifier which looks like this: D-04235
In the Demand object, the field is defined as:
Now, in the developer console I can write the below SOQL query:
Select Name, Id from apm2__Demand__c where Id ='a0U8E000002tZwj'
and it returns a record with the results as below:
In my VF page, I want to show the Name field from the demand object, which should be D-04235
but the when I run my VF page, all I can see in the log (developer console) is:
so it just stops with that error after the line system.debug('SystemChangeRequest View/Edit PAGE GET DEMAND QRY');
so what am I doing wrong?