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
GargGarg 

Compile Error: Arithmetic expressions must use numeric arguments at line

Hi All,

I am writting a trigger in which I am using:

Testpro__c.AllowableLimit__c = Testpro__c.AllowableLimit__c-i;

Where i is an integer, with value=1 where as AllowableLimit__c is a field of number type and have default value of 10,

When in my trigger I am trying to save this line- I am getting error:

Error: Compile Error: Arithmetic expressions must use numeric arguments at line 12 column 32

My full trigger code is:
trigger testpatpro on Testpatient__c (before insert, before update, after insert) {
Integer i;
i=1;
for ( Testpatient__c T : Trigger.New)
{

if(Testpatient__c.Testpro__c!= Null)

{


Testpro__c.AllowableLimit__c = Testpro__c.AllowableLimit__c -i ;
System.debug('Test');
}
}
}

where Testpatient__c and Testpro__c object have look up relationship.

I know its due to mismatch of Datatype, any idea how I can rectify it (at line# 12)

Thanks

Avidev9Avidev9

Well seems like "AllowableLimit__c" is not a number field.

Make sure it is defined as Number field.

 

Go to field and check the field Datatype. Most probably its a text

Sean TanSean Tan

I think it's just a syntax issue...

 

You're looping through the Testpatient__c records and declaring each iteration with a variable of T... but when you accessing the properties you're not using the variable of T. Try this:

 

trigger testpatpro on Testpatient__c (before insert, before update, after insert) {
    Integer i;
    i=1;
    for ( Testpatient__c T : Trigger.New)
    {        
        if(T.Testpro__c!= Null)        
        {
            T.AllowableLimit__c = T.AllowableLimit__c - i;
            System.debug('Test');
        }
    }
}