You need to sign in to do that
Don't have an account?
Error: Compile Error: Illegal assignment from LIST<Account> to LIST<Account> at line 12 column 9
MY Vf Page
<apex:page controller="SubmitCaseController">
<h1>Submit New Case</h1>
<apex:form >
<apex:pageMessages />
<table>
<tr>
<th>Your Name:</th>
<td><apex:inputText value="{!c.SuppliedName}"/></td>
</tr>
<tr>
<th>Your Email:</th>
<td><apex:inputText value="{!c.SuppliedEmail}"/></td>
</tr>
<tr>
<th>Your Account Number:</th>
<td><apex:inputText required="true" value="{!acctNum}"/></td>
</tr>
<tr>
<th>Title:</th>
<td><apex:inputText required="true" value="{!c.Subject}"/></td>
</tr>
<tr>
<th>Your Problem:</th>
<td><apex:inputTextArea required="true" rows="5" value="{!c.Description}"/></td>
</tr>
<tr>
<td><apex:commandButton value="Submit Case" action="{!submitCase}"/></td>
</tr>
</table>
</apex:form>
</apex:page>
Apex Class---->>
public class SubmitCaseController {
public Case c { get; set; }
public String acctNum { get; set; }
public SubmitCaseController() {
c = new Case();
}
public PageReference submitCase() {
List<Account> accts = [SELECT Id FROM Account WHERE AccountNumber = :acctNum]; //error occuring point
if (accts.size() != 1) {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Invalid account number');
ApexPages.addMessage(msg);
return null;
} else {
try {
c.AccountId = accts.get(0).Id;
// now look for an associated contact with the same email
Contact cnt = [SELECT Id FROM Contact WHERE AccountId = :c.AccountId AND Email = :c.SuppliedEmail LIMIT 1];
if (cnt != null)
c.ContactId = cnt.Id;
// Specify DML options to ensure the assignment rules are executed
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.assignmentRuleHeader.useDefaultRule = true;
c.setOptions(dmlOpts);
// Insert the case
INSERT c;
return new PageReference('/thanks');
} catch (Exception e) {
ApexPages.addMessages(e);
return null;
}
}
}
}
How can i slove this...??
check this link similar issues as you are facing.
http://boards.developerforce.com/t5/Visualforce-Development/Illegal-assignment-from-LIST-lt-Account-gt-to-LIST-lt-Account-gt/td-p/475211