+ Start a Discussion
zen_njzen_nj 

getting compile error: Illegal assignment from Id to SOBJECT

Hi

I am writing an apex code (in visualforce page) where I have the following three objects:

standard object Account
standard object Case
custom object FSL, which contains a lookup field called Account__c that is a lookup to Account object.

So in my code, I am doing something like this:

FSL a;
Case cases;

a = [select id,Account__c, xxx   from FSL where id = :ApexPages.currentPage().getParameters().get('id')];

// so this will return one entry from the FSL custom object which will contain the id, the Account__c value)

// and now I would like to create a Case where the Account Name in the Case object is the same as the Account that was
// referenced in my FSL object.

cases.Account=a.Account__c;

However, this will throw the following compiler error:
Illegal assignemnt from Id to SOBJECT

I remember reading something about this and I think there's a way to get around this, but not sure what exactly I can do?

Any help would be greatly appreciated! thx.

JimRaeJimRae
I think you need to set the AccountID on the Cases object.

cases.AccountID=a.Account__c;

Account is the key name, if you were referencing elements of the Account that is related.
For example. Cases.Account.Name would return the name of the Account that the value of Cases.AccountID is set to.
zen_njzen_nj
Boy do I feel stupid. lol

thx. That worked.