I'm an Apex beginner. I have a publically visible Force.com site/page that references an Apex class/controller. The page functions as a web form so customers can submit/create a case.
Because the page is public, I don't display any Account info. But I ask users to complete two mandatory fields on the web form before submitting a case so I can manually lookup/verify the Account info after the case is created:
- Company ID = {!Case.CompanyID__c}
- Company Name = {!Case.SuppliedCompany}
After clicking the submit button, I'd like to apply the following logic before the case is created so I don't need to manually lookup the Account info after the case is created. But I don't know how or where to code it:
1.IF the value in the 'Company ID' web form field {!Case.CompanyID__c} is an exact match on the 'Company ID' field in the Account table {!Account.CompanyID__c}, use value {!Account.CompanyID__c} to look up the 'Account Name' {!Account.Name} so we can populate the case's 'Account Name' field {!Case.Account} when the case is created.
2.ELSE IF the value in the 'Company Name' web form field {!Case.SuppliedCompany} is a match (not case sensitive) on the 'Account Name' field in the Account table {!Account.Name}, use value {!Account.Name} so we can populate the case's 'Account Name' field {!Case.Account} when the case is created.
3.ELSE leave the ‘Account Name’ field {!Case.Account} blank when the case is created