You need to sign in to do that
Don't have an account?
Ashok S 7
how to slove this requirment
hai guys,
I have one requirments i have two objects one is x and another one is y . x and y have lookup relationship x object contains two fields.
1.primary exp.2.secondary exp. y object contains role field it is a picklist field when role value is primary then increment primary exp the value in the x object same as when role value is secondary then increment secondary exp value in the x object.
how can i slove this requirment .please help me urgent
I have one requirments i have two objects one is x and another one is y . x and y have lookup relationship x object contains two fields.
1.primary exp.2.secondary exp. y object contains role field it is a picklist field when role value is primary then increment primary exp the value in the x object same as when role value is secondary then increment secondary exp value in the x object.
how can i slove this requirment .please help me urgent
in x object primary exp is a field which is number data type i did not give any value.
when in the y object role field is == 'primary' and click on save after in x object primary exp field become value '1'
Please find the below code
trigger CalucateNumberContact on Contacts_Involved_in_Procedure__c (After insert,After update,After delete)
{
Set<Id> ContactIds=new Set<Id>();
List<Contact> updateAccount=new List<Contact>();
contact co = new contact();
co.Primary = 0;
if(Trigger.isInsert||Trigger.isUpdate){
for(Contacts_Involved_in_Procedure__c accountdata:Trigger.new){
ContactIds.add(accountdata.Contact__c);
}
}
if(Trigger.isdelete)
{
for(Contacts_Involved_in_Procedure__c oldacc:Trigger.old){
ContactIds.add(oldacc.Contact__c);
}
}
List<Contact> Listaccount=[select id,Primary from Contact where Id=:ContactIds];
List<Contacts_Involved_in_Procedure__c> contac= [select id ,Role__c from Contacts_Involved_in_Procedure__c where Contact__c=:ContactIds];
Integer count=0;
if(con1.Role__c=='Primary Operator' || con1.Role__c=='Primary Echocardiologist'){
count++;
for(Contact acc12:Listaccount)
{
acc12.Primary =count;
}
}
}
update Listaccount;
}
and it is incrementing. When i deleted all the record the primary value is not coming to hte zero.please refer below pic.
in the above pic contact is the x object and contacts attending is the y object.Here in the contact attending there is no record i deleted but the above primary value is "1" not "0".
please help any one .Urgent
please help me
Please use the below code sample