Reply
Newbie
pokiri
Posts: 1
0

Invalid field fee for SObject student__c at line 8 column 11

trigger newinsert on student__C(before insert)
{
list<student__c>st_list=trigger.new;
for(student__c st:st_list)
{
if(st.country__C='india')
{
st.fee__C=st.fee-st.fee__c*0.1;
}
if(st.country__C='us')
{
st.fee__C=st.fee-st.fee__c*0.2;
}
if(st.country__C='uk')
{
st.fee__c=st.fee-st.fee__c*0.3;
}
else
{
st.fee__c=st.fee-st.fee__C*0.05;
}
}
}

Regular Contributor
Kartik
Posts: 127
0

Re: Invalid field fee for SObject student__c at line 8 column 11

Please do not post these kind of code snippets without any comments.
Looking at your code "st.fee" is invalid. Please use st.fee__c when doing the calculation.
Thanks.
Kartik Viswanadha | Force.com Developer | @logontokartik | http://peregrinusforce.com
Regular Contributor
ibtesam
Posts: 88
0

Re: Invalid field fee for SObject student__c at line 8 column 11

Try with this code,

 

trigger newinsert on student__C(before insert){
        for(student__c st:trigger.new){
            if(st.country__C='india') { st.fee__C=st.fee__c-st.fee__c*0.1; }
            if(st.country__C='us') { st.fee__C=st.fee-st.fee__c*0.2; }
            if(st.country__C='uk') { st.fee__c=st.fee-st.fee__c*0.3; }
            else { st.fee__c=st.fee-st.fee__C*0.05; }
    }
}