Skip to main content

Notifications

Announcements

No record found.

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 404
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
    8,311 Super User 2025 Season 1 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:
  • D365FO DEV Profile Picture
    404 on at
    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
    8,311 Super User 2025 Season 1 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
  • D365FO DEV Profile Picture
    404 on at
    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
    8,311 Super User 2025 Season 1 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
  • D365FO DEV Profile Picture
    404 on at
    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
    8,311 Super User 2025 Season 1 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
    8,311 Super User 2025 Season 1 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
    ​​​​​​​
     

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

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,017 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans