You need to sign in to do that
Don't have an account?
Sylvio Avilla
Initial term of field expression must be a concrete SObject: Id - Retreive Value from Field, based on ID
Hello,
I'm trying to solve a problem for a few days now and decided to ask for help, once again ... :S
Here is part of my code.
Basically I got a list:
Got the record ID
Now is the problem. For some reason, cannot find a way to retrieve the DateTime1__c value, using the ID, and receive the following error
"Initial term of field expression must be a concrete SObject: Id"
Thanks
I'm trying to solve a problem for a few days now and decided to ask for help, once again ... :S
Here is part of my code.
Basically I got a list:
List<CustomObject__c> lstMyObjects = [Select ID, Name, DateTime1__c,DateTime2__c from CustomObject__c ];Found the difference between all DateTime and Sorted It:
for(Integer i=0; i<lstMyObjects.size();i++){ Long myValue = 0; Long dt1Long = (lstMyObjects[i+1].Field1__c.getTime())/1000; Long dt2Long = (lstMyObjects[i].Field2__c.getTime())/1000; myValue = (dt1Long-dt2Long)/60; idDt1.put(myValue,lstMyObjects[i+1].ID); idDt2.put(myValue,lstMyObjects[i].ID); } myValues.add(myValue); (myValues.sort());Now I've got the second greatest difference between DateTime value
Got the record ID
Now is the problem. For some reason, cannot find a way to retrieve the DateTime1__c value, using the ID, and receive the following error
"Initial term of field expression must be a concrete SObject: Id"
Id test = idDt1.get(myValues[myValues.size()-2]); long time = test.DateTime1__c.getTime()/1000; }Don't know if it was clear enough, but hope someone could help me!
Thanks
Correct me if I am wrong. You are getting the error on below line. The error is because you are putting Id as the value in Map and then trying to access custom field of that Object using Id. If you are accessing any field then it must be Object. Like lstMyObjects[i+1].Field1__c.getTime()
If yes then use below code. Let me know if this helps :)
Thanks!
Amit