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
Zeeshan Moulvi 2Zeeshan Moulvi 2 

Simple Trigger to Calculate Math.ABS

Hi Team,

We are trying to implement a validation on Quote Page by using the below formula. 

IF (Service_Total_Net_Price_c _< 0 and ABSOLUTEVALUE Service_Total_Net_Pricec _ > ABSOLUTEVALUE _Total_Service_Margin_c )

Here is the Trigger which I have created but I'm getting an error while trying to save the trigger, Can anyone please take a look and let me know what is the issue.

trigger CustomQuoteValidation on SBQQ__Quote__c (before insert) {
for (SBQQ__Quote__c a : Trigger.new) {
  if (a.Service_Total_Net_Price__c < 0 && (MATH.ABS(a.Service_Total_Net_Price__c > a.Total_Service_Margin__c ) )) {
    a.addError('Your custom error message');
  }
}
}


Thanks,
Zeeshan.
v varaprasadv varaprasad
Hi Zeeshan,

Please check once below code : 
trigger CustomQuoteValidation on SBQQ__Quote__c (before insert) {
for (SBQQ__Quote__c a : Trigger.new) {
  if (a.Service_Total_Net_Price__c < 0 &&(a.Service_Total_Net_Price__c > a.Total_Service_Margin__c ) ) {
    a.addError('Your custom error message');
  }
}
}



Hope this helps you!

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com

 
Zeeshan Moulvi 2Zeeshan Moulvi 2
Hello Varaprasad,

Thanks for quick response. Is it possible have the absolute value for (a.Service_Total_Net_Price__c > a.Total_Service_Margin__c) as we have a negative sign in one of the value?

Thanks,
Zeeshan.