Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to get a proper output through trigger after insert salesforce?

Asked by David Edmunds May 16, 2023 813 views 1 answer
Share

About this question

I Created an object called Percentile with 10 fields and created one more field called Percentage. If I enter a value for one field and if I save it, Then the Percentage field value should be updated with 10 %. Same like that if I enter a value for two fields, Then the Percentage field value should be updated with 20 % and vice versa. I am not getting proper output. Please provide good logic. The trigger which i had used is given below.


trigger PercentageTrigger on Percentile__c (after insert) { List percent=[select Tilte__c,Name,LastName__c,Email__c,Mobile_Number__c, Industry__c,Father_Name__c,Father_Phone_Number__c,Mother_Name__c,Mother_Phone_Number__c, Percentage__c from Percentile__c where ID IN:Trigger.NewMap.keySet()]; for(Percentile__c cent:percent){ f(cent.Name != Null){ cent.Percentage__c=10; update cent; } if(cent.Name != Null && cent.Tilte__c !=null){ cent.Percentage__c=20; update cent; } } }

Your answer

1 Answer

More Salesforce discussions