Using Formula Fields in Triggers

By | May 14, 2015

For one of our projects, we were adding some grouped products in the “Opportunity Products” object through our custom visualforce page.

This seemed a very simple technical implementation. Though it would give us ‘NULL’ reference error when our custom page would try to insert the product records in the opportunity. However, it worked seamlessly for the standard quote line items page (refer to the screen shot below).

1

When we dug into the issue we discovered that there was a cutom trigger (before insert) written on the “Opportunity Products”. This trigger was referencing the “List Price” of the product, a formula field based on the Price book entry, which was not available in the before insert operation. Therefore, every logic written on the basis of this field would fail.

This issue can be easily resolved, all one needs to do is, query all the values for formula fields for the records to be inserted before you start processing the records in the trigger.

Happy Coding !!

About Us
Greytrix as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce integration with Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.

Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information, please contact us at salesforce@greytrix.com. We will be glad to assist you.

Related Posts