You need to sign in to do that
Don't have an account?
anillll
Incrementing two custom fields based on Location
I have two custom fields Chennai_DC_No__c,Bangalore_DC_No__c and Location__c (picklist) contains Bangalore,Chennai
One field is incrementing and another one is not incrementing , every time it display 1.
trigger ChennaiNos on Demo__c (before insert) { List<Demo__c> OpList = new List<Demo__c>(); OpList=[SELECT Chennai_DC_No__c FROM Demo__c]; for(Demo__c c : Trigger.new){ if(OpList.size() > 0){ if(c.Location__c!= 'Bangalore'){ if(OpList[0].Chennai_DC_No__c!= null){ c.Chennai_DC_No__c =OpList[0].Chennai_DC_No__c +1; } else{ c.Chennai_DC_No__c =0+1; } } } if(OpList.size() > 0){ if(c.Location__c== 'Bangalore'){ if(OpList[0].Bangalore_DC_No__c!= null){ c.Bangalore_DC_No__c =OpList[0].Bangalore_DC_No__c +1; } else{ c.Bangalore_DC_No__c =0+1; } } } } }