You need to sign in to do that
Don't have an account?
ShayKhan
Check all Account who's Type = 'Prospect' than update these account Fax Field.
Hello All,
I have a requirement that i seem to have issues with.
The requirement is to check all accounts that has the account type as 'Prospect' and update these accounts Fax field to '9999999999'
Below is the code i have formulated but it is getting Syntax errors.
I have a requirement that i seem to have issues with.
The requirement is to check all accounts that has the account type as 'Prospect' and update these accounts Fax field to '9999999999'
Below is the code i have formulated but it is getting Syntax errors.
public class AccountnContactClass{ //Create 2 account and 2 Contacts using List and Limiting the Insert DML statements public void AccountContactCreation(){ List<Account> AccList = new list <Account>(); Account ac8 = New Account(); ac8.Name = 'Apples'; ac8.type = 'prospect'; Account ac9 = New Account(); ac9.Name = 'Oranges'; ac9.type = 'prospect'; AccList.add(ac8); AccList.add(ac9); Insert AccList; List<contact> ContactList = new list <contact>(); Contact Con1 = New Contact(); Con1.FirstName = 'Tomatoes'; Con1.LastName = 'Rotten'; Con1.LeadSource = 'Phone Inquiry'; Con1.accountid = Acclist[0].id; Contact Con2 = New Contact(); Con2.FirstName = 'G2'; Con2.LastName = 'Gatorade'; Con2.LeadSource = 'Partner Referral'; Con2.accountid = AccList[1].id; ContactList.add(Con1); ContactList.add(Con2); Insert ContactList; Contact d=[select Account.name from Contact where accountid=:Acclist[0].id Limit 1]; d.account.type='Installation Partner'; update d.account; //This is the code for updating the fax field for account type prospect List<account> A = [select name, type, fax from Account where type = 'prospect']; A.account.Fax= '9999999999'; update A.account; } }
All Answers
Thanks alot!
Contact d=[select Account.name from Contact where accountid=:Acclist[0].id Limit 1];
d.account.type='Installation Partner'; update d.account;
Why you guys using above two lines. If you update account.type ='Installation partner'
then how can you update a fax field based on Type = 'Prospect';
account type field is changed to installation Partner right.
I am just asking...Can you clear me the issue