Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Branch restriction for...
Finance forum
Suggested answer

Branch restriction for journals - D365FO X++

Posted on by 318
Hello everyone,
I Require a restriction when creating a journal so that only one branch can be selected per voucher. Selecting different branches within a single voucher will not be allowed and will be restricted. Those journals are fixed asset journal, general journal, invoice journal, vendor payment journal and customer payment journal. A Boolean field must be created in the general ledger parameters. If enabled, this parameter will enforce the restriction for all specified journal types and error message will be displayed: "Choose one branch per voucher”, and the journal cannot be posted without resolving this error. If set to "no," there will be no restriction.
as you can see in the screenshot, this journal has same voucher number, but the branch is different. this should display error message if the boolean field is enabled.
 
anyone can provide like source code or guidance to accomplish this task?
 
thanks
 
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 3,324 on at
    Branch restriction for journals - D365FO X++
    Hi,
     
    Based on your last comment. You can add your code on validatewrite method, you should check if you have other journal lines have the same voucher number, if yes, then compare the line's branch with new records/modified record. Start from here and tell me if you want further help.
     
     
    You can check the following link to get branch from the financial dimension for the journal lines:
  • Branch restriction for journals - D365FO X++
    Hi @wael,
     
    i want once the user select the branhes, and click on "SAVE" to receive error message if he selected different branches for same voucher number. please provide source code if possible. im facing some challenges with this one,
    thanks

    also regarding the code behind the menu item, its  a clicked method:

    [Control("MenuFunctionButton")]
        class AccountDimension
        {
            public void clicked()
            {
                ledgerJournalEngine.openAccountFinancialDimensionForm(ledgerJournalTrans, accountDimension.menuItemType(), accountDimension.menuItemName());
            }
        }
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 3,324 on at
    Branch restriction for journals - D365FO X++
    Hi,
     
    Do you want to add it as a validation when you post the journal, you can achieve it by extending the code, you should check the code behind the button if it button or menu item, if it is a button you can use event handler for clicked on the button and  add the validation to stop the posting if the branch aren't the same for all lines.
     
    You can check the following link to get branch from the financial dimension for the journal lines:
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
  • Branch restriction for journals - D365FO X++
    Hi wael,
     
    lets say we have two lines, of type customer. and have the same voucher number. we need to select the branch in the financial dimension for each line.
     
    in this line we are adding a branch for the second line.( check below ss)
     
    we also need to apply the same for 1st line. 
     
    what i  want is if the voucher number is the same for both lines, the branch should be the same and cannot be different.
  • Waed Ayyad Profile Picture
    Waed Ayyad 3,324 on at
    Branch restriction for journals - D365FO X++
    Hi,
     
    I don't understand your question, what is the restriction that you want to achieve?
     
    Thanks,
    Waed Ayyad
  • Branch restriction for journals - D365FO X++
    Hi @wael ayyad,
     
    only one requirement missing is i also have to add the restriction on the account level in the financial dimension ( as you can see in the screenshot)
     
    can you provide me the code to make this happen, and also which method to extend?
     
    thanks.
  • Waed Ayyad Profile Picture
    Waed Ayyad 3,324 on at
    Branch restriction for journals - D365FO X++
    Hi,
     
    Is your issue resolved?  If yes, mark the answers that helped you as verified.

    Thanks,
    Waed Ayyad
  • Waed Ayyad Profile Picture
    Waed Ayyad 3,324 on at
    Branch restriction for journals - D365FO X++
    Hi,

    You can add your code on the validate write method, first of all you should check the new parameter is it on or off then add your code to check if the record has the same voucher number as other records but with different branch number.


    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
    ​​​​​​​
     

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,436 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,206 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans