-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoCompleteAccount.apxc
34 lines (30 loc) · 1.36 KB
/
AutoCompleteAccount.apxc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public class AutoCompleteAccount {
public String selectedAccountId {get;set;}
public boolean accountDetailVisible{get;set;}
public Account selectedAccount{get;set;}
public String chatterPost{get;set;}
/*
* This method get called from action function when some selects the Account from auto complete. Along with this method
* selectedAccountId variable also get updated for accessing the Id.
*/
public void showAccountDetail(){
selectedAccount = [Select Id,Name,Website,AccountNumber,Phone ,Fax FROM Account WHERE Id = :selectedAccountId LIMIT 1];
accountDetailVisible= true;
}
/*
* This method is called on "Post" button click in "Add Chatter Post" Section. In this we are creating FeedItem object
* and assigning parentId as the selectedAccountId and body as the entered text in chatterPost.
*/
public void postChatterMessage(){
if(chatterPost == null || chatterPost.trim().equals('')){
ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR,'Please Enter chatter Message to Post.'));
}else{
FeedItem feed = new FeedItem();
feed.ParentId = selectedAccountId;
feed.Body = chatterPost;
insert feed;
ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,'Your Message has been posted on Chatter'));
chatterPost = '';
}
}
}