{"id":32738,"date":"2026-10-27T10:18:06","date_gmt":"2026-10-27T10:18:06","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/sagex3\/?p=32738"},"modified":"2026-10-27T10:18:06","modified_gmt":"2026-10-27T10:18:06","slug":"dynamic-project-code-extraction-in-automatic-journal-pih2","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/10\/27\/dynamic-project-code-extraction-in-automatic-journal-pih2\/","title":{"rendered":"Dynamic Project Code Extraction in Automatic Journal (PIH2)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/development-services\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.greytrix.com\/sage-x3-erp\/development-services\/\" rel=\"noreferrer noopener\">Sage X3<\/a>, 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>New Stuff:<\/strong> <a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/10\/12\/holiday-shipping-preparation-in-sage-x3-with-gumu-shipeazy\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/10\/12\/holiday-shipping-preparation-in-sage-x3-with-gumu-shipeazy\/\" rel=\"noreferrer noopener\">Holiday Shipping Preparation in Sage X3 with GUMU&#x2122; ShipEazy<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Recently, a client faced a posting error on a purchase invoice. The issue was related to the formula used in the Automatic Journal (PIH2 \u2013 Identification Key).<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Purchase-Invoice-Posting-Error.png\" target=\"_blank\" rel=\"noreferrer \nnoopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; \nalign: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Purchase-Invoice-Posting-Error.png\" alt=\"Purchase Invoice Posting Error\"><\/a><\/center> \n<font size=\"2\"><center>Purchase Invoice Posting Error<\/center><\/font>\n\n\n\n<p class=\"wp-block-paragraph\">In the Identification Key of the Automatic Journal, the following formula was already configured as a custom change as shown in below fig2.<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Automatic-journal-PIH2-Identification-key-1024x364.png\" target=\"_blank\" rel=\"noreferrer \nnoopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; \nalign: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Automatic-journal-PIH2-Identification-key-1024x364.png\" alt=\"Automatic journal PIH2 Identification key\"><\/a><\/center> \n<font size=\"2\"><center>Automatic journal PIH2 Identification key<\/center><\/font>\n\n\n\n<p class=\"wp-block-paragraph\">This formula was extracting only the first 8 characters. However, this approach was not reliable and could not be continued.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this format, the part before the \u201c!\u201d represents the actual Project Code (ZME-INT-0030), while the part after the \u201c!\u201d contains additional information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To handle this dynamically, we created a reusable function that checks for the presence of the ! character and extracts the correct project code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the project value contains \u201c!\u201d, extract everything before the first \u201c!\u201d as the actual Project Code. If there is no \u201c!\u201d, take the complete value as the Project Code. This ensures that the function works correctly for project codes of any length.<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Project-extract-function.png\" target=\"_blank\" rel=\"noreferrer \nnoopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; \nalign: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Project-extract-function.png\" alt=\"Project extract function\"><\/a><\/center> \n<font size=\"2\"><center>Project extract function<\/center><\/font>\n\n\n\n<p class=\"wp-block-paragraph\">Please follow the steps given below :<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">-Created the above function ZAPP.<br>-Compiled the script.(ZPJM).<br>-In the PIH2 Identification Key, replaced the old fixed formula &#8211; func ZPJM.ZAPP([F:PID]PJT)<br>-Attached the function so that the Automatic Journal now dynamically extracts the correct project code based on the standard ! separator format.<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Replace-Project-Identification-Key-with-Custom-Project-Function-ZAPP-1024x410.png\" target=\"_blank\" rel=\"noreferrer \nnoopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; \nalign: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-content\/uploads\/2026\/10\/Replace-Project-Identification-Key-with-Custom-Project-Function-ZAPP-1024x410.png\" alt=\"Replace Project Identification Key with Custom Project Function ZAPP\"><\/a><\/center> \n<font size=\"2\"><center>Replace Project Identification Key with Custom Project Function ZAPP<\/center><\/font>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-1\" style=\"color:#c71d22\"><strong>About Us<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Greytrix \u2013 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-28013e99-0882-44c6-b705-7b16c85053b2\">Greytrix&nbsp;has some unique integration solutions developed for&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-crm\/\">Sage CRM<\/a>&nbsp;with Sage ERPs&nbsp;namely&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/\">Sage X3<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-intacct\/\">Sage Intacct<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-100-erp\/\">Sage 100<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-500-erp\/\">Sage 500<\/a>,&nbsp;and&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-300-erp\/\">Sage 300<\/a>. We also offer best-in-class&nbsp;Sage ERP&nbsp;and&nbsp;Sage CRM&nbsp;customization and development services&nbsp;to&nbsp;Business&nbsp;Partners,&nbsp;End&nbsp;Users, and Sage PSG worldwide. Greytrix&nbsp;helps in&nbsp;the migration of Sage CRM from&nbsp;Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes&nbsp;addons like&nbsp;&nbsp;Greytrix Business Manager,&nbsp;Sage CRM Project Manager,&nbsp;Sage CRM Resource Planner,&nbsp;Sage CRM Contract Manager,&nbsp;Sage CRM Event Manager,&nbsp;Sage CRM Budget Planner,&nbsp;Gmail Integration,&nbsp;Sage CRM Mobile Service Signature,&nbsp;Sage CRM CTI Framework.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-4bc42a09-fb13-4598-8137-ce5f7b91ce28\">Greytrix is a recognized&nbsp;Sage Champion Partner&nbsp;for GUMU&#x2122; Sage X3 \u2013 Sage CRM integration listed on&nbsp;<a href=\"https:\/\/www.sage.com\/marketplace\/asb_ListingDetail?listingId=a1h24000007PC3aAAG\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Marketplace<\/a>&nbsp;and Sage CRM \u2013 Sage Intacct integration listed on&nbsp;<a href=\"https:\/\/marketplace.intacct.com\/MPListing?lid=a2D0H000007kiHyUAI\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Intacct Marketplace<\/a>. The&nbsp;<a href=\"https:\/\/www.greytrix.com\/gumu\/\" target=\"_blank\" rel=\"noreferrer noopener\">GUMU&#x2122; Cloud framework<\/a>&nbsp;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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-76376301-1c3e-4250-8a09-727595a606f0\">For more information on our integration solutions, please contact us at&nbsp;<a href=\"mailto:sage@greytrix.com\">sage@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#x2122; ShipEazy Recently, a client faced a posting error on a purchase invoice. The issue\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/10\/27\/dynamic-project-code-extraction-in-automatic-journal-pih2\/\">Read More: Dynamic Project Code Extraction in Automatic Journal (PIH2) &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,13,8],"tags":[176,4744,4743,4745],"class_list":["post-32738","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-integration","category-sage-erp-x3","tag-automatic-journal","tag-project-code","tag-project-code-extract-function","tag-purchase-invoice-posting-error"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/32738","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/comments?post=32738"}],"version-history":[{"count":6,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/32738\/revisions"}],"predecessor-version":[{"id":32744,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/32738\/revisions\/32744"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/media?parent=32738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/categories?post=32738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/tags?post=32738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}