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 

Error: 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 = 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 6 column 63

My full trigger code is:
trigger testpatpro on Testpatient__c (before insert, before update) {
Integer i;
i=1;
if(Testpatient__c.Testpro__c!= Null)
{
//Testpro__c.AllowableLimit__c = 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.

Thanks

bob_buzzardbob_buzzard

There are a few problems there:

 

TestPatient__c isn't declared anywhere - if it is a record from the trigger you'll need to use trigger.new to access it.

 

TestPro__c isn't declared anywhere either - did you mean to have a TestPatient__c in front of it (assuming you had declared it properly?)

 

If you want to update fields on the related testpro__c record for each testpatent__c in the trigger, you'll need to iterate the trigger records and retrieve the related testpro__c records and save them once updated, as related objects aren't populated for records in a trigger.

gedeefgedeef
why do you have "Testpro__c.AllowableLimit__c =" twice ?
sandeep@Salesforcesandeep@Salesforce

trigger testpatpro on Testpatient__c (before insert, before update) {
Integer i;
i=1;
if(Testpatient__c.Testpro__c!= Null)
{
//Testpro__c.AllowableLimit__c = Testpro__c.AllowableLimit__c = Testpro__c.AllowableLimit__c-i;

System.debug('Test');
}
}

 

In red line first of all you need to declare varible like 

 

for ( Testpatient__c T : Trigger.New)