Skip to main content

Notifications

Announcements

No record found.

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

Branch restriction for journals - D365FO X++

Posted on by 320
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,758 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
    D365FO DEV 320 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
    Waed Ayyad 3,758 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
    D365FO DEV 320 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
    Waed Ayyad 3,758 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
    D365FO DEV 320 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
    Waed Ayyad 3,758 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,758 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

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans