web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Branch restriction for journals - D365FO X++

(1) ShareShare
ReportReport
Posted on by 406
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
 
I have the same question (0)
  • Waed Ayyad Profile Picture
    9,047 Super User 2025 Season 2 on at
    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
    ​​​​​​​
     
  • Waed Ayyad Profile Picture
    9,047 Super User 2025 Season 2 on at
    Hi,
     
    Is your issue resolved?  If yes, mark the answers that helped you as verified.

    Thanks,
    Waed Ayyad
  • D365FO DEV Profile Picture
    406 on at
    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
    9,047 Super User 2025 Season 2 on at
    Hi,
     
    I don't understand your question, what is the restriction that you want to achieve?
     
    Thanks,
    Waed Ayyad
  • D365FO DEV Profile Picture
    406 on at
    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.
  • Suggested answer
    Waed Ayyad Profile Picture
    9,047 Super User 2025 Season 2 on at
    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
  • D365FO DEV Profile Picture
    406 on at
    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
    9,047 Super User 2025 Season 2 on at
    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:

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 732 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 413 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 289 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans