You need to sign in to do that
Don't have an account?
Siva Sakthi
I have below requirement with Apex Coding
Hi
1. Create a field “Number of attachments “in accounts. Whenever an attachment is attached or deleted from the account, count the number of attachments and display in the field.
2. Create a Page with two buttons “Start” and ”Increment” .When “Start” is clicked start a counter decrementing from 60 seconds. When the “Increment” button is clicked 3 times stop the counter. Else after 60 seconds display an alert message.
How to achive this two scenario. Please guide me to solve this issue.Post some code to achive this.
Advance Thanks
Maheshwar
1. Create a field “Number of attachments “in accounts. Whenever an attachment is attached or deleted from the account, count the number of attachments and display in the field.
2. Create a Page with two buttons “Start” and ”Increment” .When “Start” is clicked start a counter decrementing from 60 seconds. When the “Increment” button is clicked 3 times stop the counter. Else after 60 seconds display an alert message.
How to achive this two scenario. Please guide me to solve this issue.Post some code to achive this.
Advance Thanks
Maheshwar
VF Page: Controller: For the second requirement (It needs to be implemented using Wrapper Class), more details are needed as to the type of Object and Fields being used as I am not clear on how its being represented currently.
All Answers
You need to write a trigger on Attachment standard object. I've provided you code when attachment is newly attached.
Now you need to hanlde the case of Delete of Attachment than decrease the counter.
-Thanks
Ashlekh Gera
Error: Compile Error: Incorrect SObject type: Attachment should be Account at line 1 column 1
trigger attechmentcount on Attachment(after insert,before delete) {
List<Account> acclist = new List<Account>();
Map<id,integer> accoutMAP = new Map<id,integer>();
if(Trigger.isAfter && Trigger.isinsert) {
for(Attachment att: Trigger.new )
{
String prefix = att.ParentId;
if(prefix.startsWith('001'))
{
if(accoutMAP.containsKey(prefix))
{
accoutMAP.put(prefix, accoutMAP.get(prefix)+1);
}else{
accoutMAP.put(prefix,1);
}
}
}
if(accoutMAP.size()>0) {
for(Account c:[select id,Attachment_Count__c from Account where id in :accoutMAP.keySet()]) {
c.Attachment_Count__c = c.Attachment_Count__c==null?accoutMAP.get(c.id):c.Attachment_Count__c+accoutMAP.get(c.id);
acclist.add(c);
}
if(acclist.size()>0)
update acclist;
}
}
/* if(Trigger.isBefore && Trigger.isdelete) {
NEED TO WRITE A CODE FOR DELETE CASE
}*/
}
I am getting Error Like :
Error: Compile Error: Incorrect SObject type: Attachment should be Account at line 1 column 1
Thank you Siddharth ! Its working Fine
a) Create the following “Order” Table in Database with columns “Item Type” ,“Price” and ”Customer”. Display a list of only the highest price in each Item Type with the customer Name (VF Page).
b) Display the List of Employees with Attendance Percentage without duplicates, in a table with a checkbox by the side. Have a button “Calculate Attendance” which when clicked displays the Attendance for only for the Employee whose checkboxes are checked.
Advance Thanks
SivaSakthi
VF Page: Controller: For the second requirement (It needs to be implemented using Wrapper Class), more details are needed as to the type of Object and Fields being used as I am not clear on how its being represented currently.