Fixing Journal Posting Rule

WARNING – EXPERTS ONLY

Journal Posting problems

If you heavily customise posting rules, I’m sure you will have come across this problem. The posting rules look fine, but when you add a new Journal the UX does not ask for the right fields, or the journal just fails to post. Here is a video showing the problem:

My guess is it is some kind of caching of the posting rules and my normal way around this was to clone the Journal Type and the clone would work fine. However, if you already have transactions using the Journal Type that is not a viable option, and I’ve been having problems with Journal cloning…

What you need to do is give the Journal Type a real good kicking, and here is some APEX code which will do just that if you run it in ‘Execute Anonymous’ :

 // This will remove all the posting rules from a Journal Type and then re connect them.
id lvTargetJournalTypeID = 'a0r1v00000gXPiBAAW'; //The Journal you are trying to fix
id lvDummyJournalTypeId = 'a0r1v00000hIPZ5AAO'; //Some other Journal

List<s2cor__Sage_ACC_Posting_Rule__c> lvPostingRuleList = [Select s2cor__Journal_Type__c, Name, Id 
   From s2cor__Sage_ACC_Posting_Rule__c
   where s2cor__Journal_Type__c = : lvTargetJournalTypeID];
system.debug('Update ' + lvPostingRuleList.size() + ' posting rules');

for(s2cor__Sage_ACC_Posting_Rule__c lvPostingRule : lvPostingRuleList){
   lvPostingRule.s2cor__Journal_Type__c = lvDummyJournalTypeId;
}

update lvPostingRuleList;

for(s2cor__Sage_ACC_Posting_Rule__c lvPostingRule : lvPostingRuleList){
   lvPostingRule.s2cor__Journal_Type__c = lvTargetJournalTypeID;
}

update lvPostingRuleList;

 

The TargetJournalTypeID is the Id of the Journal Type you are trying to fix, the DummyJournalTypeID  is some other Journal Type. The code moves all the posting rules to the DummyJournalType and then moves them all back again. This seems to fire something in Financials which clears out the problem.

WARNING – EXPERTS ONLY

If you don’t know how to get the Journal Type Id’s or you don’t know what ‘Execute Anonymous’  is DO NOT try this.

In best Blue Peter tradition:

DO NOT TRY THIS AT HOME

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *