You need to sign in to do that
Don't have an account?
Galeeb SK
Update Count
Hi
I am tried to update the count of Records,But it's not working Properly.Tell me where can make the Mistake,
Scenario:
I have two objects Position,Job Application.JobApplication has the Status field it contans picklist values Open,New,Closed.when i create record in JobApplication,I need only 'Closed ' records count that should be update in Position .
Apart from that i have 5 Closed Records ,5 Open Records then how can i display the count individually in same Trigger.
Tell me Please.
My Code Is:
trigger countupdate on Job_Application__c (before insert,before update){
set<ID>sid=new set<ID>();
list<Position__c> PosRec=new list<Position__c>();
for(Job_Application__c job :trigger.new)
{
//sid.add(job.Position__c);
list<Position__c>Pos =[SELECT ID,Count__c,(SELECT ID,Status__c FROM Job_Applications2__r) FROM Position__c WHERE ID =:job.id];
for(Position__c P:Pos){
if(job.Status__c=='Closed')
{
P.Count__c=P.Job_Applications2__r.size();
}
else{
//P.Count__c=P.Job_Applications2__r.size();
P.Count__c=0;
}
PosRec.add(P);
}
}
update PosRec;
}
Thanks
Galeeb SK
I am tried to update the count of Records,But it's not working Properly.Tell me where can make the Mistake,
Scenario:
I have two objects Position,Job Application.JobApplication has the Status field it contans picklist values Open,New,Closed.when i create record in JobApplication,I need only 'Closed ' records count that should be update in Position .
Apart from that i have 5 Closed Records ,5 Open Records then how can i display the count individually in same Trigger.
Tell me Please.
My Code Is:
trigger countupdate on Job_Application__c (before insert,before update){
set<ID>sid=new set<ID>();
list<Position__c> PosRec=new list<Position__c>();
for(Job_Application__c job :trigger.new)
{
//sid.add(job.Position__c);
list<Position__c>Pos =[SELECT ID,Count__c,(SELECT ID,Status__c FROM Job_Applications2__r) FROM Position__c WHERE ID =:job.id];
for(Position__c P:Pos){
if(job.Status__c=='Closed')
{
P.Count__c=P.Job_Applications2__r.size();
}
else{
//P.Count__c=P.Job_Applications2__r.size();
P.Count__c=0;
}
PosRec.add(P);
}
}
update PosRec;
}
Thanks
Galeeb SK
If master detail relation ship is there then no need to write Trigger.
Please try once rollup summary field. like below...
let me know this is correct or not..
Thanks
Not configuration,we will achieve through coding.In Lookup also we can perform record count.but here we can display perticular picklist record count.
Thanks
Galeeb Sk