In Sage X3, Automatic Journals are widely used to derive values dynamically during invoice posting. One common requirement is to extract the correct Project Code from the purchase invoice details line.
New Stuff: Holiday Shipping Preparation in Sage X3 with GUMU™ ShipEazy
Recently, a client faced a posting error on a purchase invoice. The issue was related to the formula used in the Automatic Journal (PIH2 – Identification Key).

In the Identification Key of the Automatic Journal, the following formula was already configured as a custom change as shown in below fig2.

This formula was extracting only the first 8 characters. However, this approach was not reliable and could not be continued.
When the Project is added in the Automatic Journal line, we cannot directly put the project code. The system expects the value in a specific standard format. e.g ZME-INT-0030!CTC-003C
In this format, the part before the “!” represents the actual Project Code (ZME-INT-0030), while the part after the “!” contains additional information.
Because the length of the project code is not fixed and the value always contains the ! separator, using a fixed left$ formula was causing incorrect extraction and posting failures.
To handle this dynamically, we created a reusable function that checks for the presence of the ! character and extracts the correct project code.
If the project value contains “!”, extract everything before the first “!” as the actual Project Code. If there is no “!”, take the complete value as the Project Code. This ensures that the function works correctly for project codes of any length.

Please follow the steps given below :
-Created the above function ZAPP.
-Compiled the script.(ZPJM).
-In the PIH2 Identification Key, replaced the old fixed formula – func ZPJM.ZAPP([F:PID]PJT)
-Attached the function so that the Automatic Journal now dynamically extracts the correct project code based on the standard ! separator format.

By understanding the standard project format (XXXX!YYYY) and replacing the fixed-length formula with a dynamic function, we successfully resolved the posting issue and made the Automatic Journal configuration flexible for all project codes.
About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partners is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience and expertise, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development, and implementation competence.
Greytrix has some unique integration solutions developed for Sage CRM with Sage ERPs namely Sage X3, Sage Intacct, Sage 100, Sage 500, and Sage 300. We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users, and Sage PSG worldwide. Greytrix helps in the migration of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes addons like Greytrix Business Manager, Sage CRM Project Manager, Sage CRM Resource Planner, Sage CRM Contract Manager, Sage CRM Event Manager, Sage CRM Budget Planner, Gmail Integration, Sage CRM Mobile Service Signature, Sage CRM CTI Framework.
Greytrix is a recognized Sage Champion Partner for GUMU™ Sage X3 – Sage CRM integration listed on Sage Marketplace and Sage CRM – Sage Intacct integration listed on Sage Intacct Marketplace. The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for the processing and execution of application programs at the click of a button.
For more information on our integration solutions, please contact us at sage@greytrix.com. We will be glad to assist you.