function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
raja subbu 1raja subbu 1 

i got a task on trigger.i created an object called data and created two fields one is country a picklist and and fee.i want to give discount on fee base on country value.i am getting error as condition expression must be type of boolean:string .plz help

this is my code

trigger trg12 on data__c (before insert) {
list<data__c>stu=trigger.new;
    for(data__c s:trigger.new){
        if(s.country__c='usa') {
            double p;
            p=s.fee__c*0.2;
            s.fee__c =s.fee__c - p;
        }
        
        
    } 
Best Answer chosen by raja subbu 1
Ahmed Ansari 13Ahmed Ansari 13
Hiii

Please try this

trigger trg12 on data__c (before insert) {
    for(data__c s:trigger.new){
    double p;
        if(s.country__c=='usa') {
            p=s.fee__c*0.2;
            s.fee__c =s.fee__c - p;
        }
    } 
}

All Answers

Ahmed Ansari 13Ahmed Ansari 13
Hiii

Please try this

trigger trg12 on data__c (before insert) {
    for(data__c s:trigger.new){
    double p;
        if(s.country__c=='usa') {
            p=s.fee__c*0.2;
            s.fee__c =s.fee__c - p;
        }
    } 
}
This was selected as the best answer
raja subbu 1raja subbu 1
currency
 
raja subbu 1raja subbu 1
its working i did small mistake.i used  single '=' instead of '==' thank you brother