web
You’re offline. This is a read only version of the page.
close
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

How to get the same functionality as the credit management checkpoint on sales order via code?

(5) ShareShare
ReportReport
Posted on by 183
Hi, 
I have added a new element in the credit management chekpoint with the value suppose abc. This abc button is added at sales order to work as the standard functionality as other checkpoints does. But I am unable to figure out like which class should i call so that it works as the standard functionality with check of proform, grace days and even posting the credit hold. I tried first - 
CredManRuleCheckContract contract = CredManRuleCheckContract::construct();
contract.caller = salesTable;
contract.documentStatus = DocumentStatus::Invoice;
CredManIRuleCheck ruleCheck = CredManRuleCheck::newFromContract(contract);
ruleCheck.check();

 2. Create the credit control for Invoice and trigger credit hold logic
CredManCreditControl creditControl = CredManCreditControl::newFromDocumentStatusCheck(CredManDocumentStatusCheck::Invoice);
creditControl.parmSalesTable(salesTable);
creditControl.run();
creditControl.createCreditHold();
This does perfomr the checks of credit limit but doesnt insert data into credit management hold list. Then I tried just this - 
 CredManCreditControl creditControl = CredManCreditControl::newFromDocumentStatusCheck(CredManDocumentStatusCheck::Invoice);
 creditControl.parmSalesTable(salesTable);

 // This will check the rules and insert into CredManTable if needed
 creditControl.run();
This didnt even check the rules for credit management and neither did add line to credit management list. 
 
Please let me know how can i achieve this functionality or tell me where am I wrong. Thanks in advance.
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,917 Super User 2025 Season 2 on at
    Hi Spidey1010,
     
    Can you provide screenshots or examples about what you want to achieve from a functional point of view? Can you also clarify what exact product you are using as you added the Dynamics 365 Finance and Microsoft Dynamics AX tags. Or do you need to build something for both products?
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at
    Classical one, that I have seen over the years, growing up with the ERP (though I could be wrong), but please allow me to say what I think on this.
     
    I reckon you are talking about one of those classic quirks in Dynamics AX (or Axapta, as some of us still call it), where the system doesn’t always show you everything until after you’ve posted it.
     
    A good example I remember from back in the days, when I was young, is how sales tax is calculated on a Sales Invoice. The code you need to calculate the tax before posting is different from what you’d use after  posting. And there’s actually a good reason for that.
     
    I will give you a good example, here:
     
    If the Sales Invoice hasn’t been posted yet:
        Use Method A to calculate tax
    If it has been posted:
        Then you’ve got to use Method B
     
    The thing is, a sales order is really just a statement of intent. Not a proper financial commitment. So, even if the order says 15 units, there’s nothing stopping the customer from changing their mind and only going for 10 in the end.
     
    You can have an order or quantity 50 but with 4 invoices of 10 quantity each (total sales 40, not 50)
     
    That’s why the system behaves differently before and after posting. Because nothing's final until it’s posted.
     
    You may want to use CredManCreditControl_SalesFormLetter::newFromDocumentStatusCheck because of the reasons I have mentioned)
     
    As André said, if you can share a few screenshots, we’ll happily take a look, to try to help.
     
    Thank you!

     
  • spidey1010 Profile Picture
    183 on at
    Hi, 
    Thanks for the reply. I have added a new enum value check here -  
     
    And under sales order I have a new button called check which will check for the credit managemente checkpoint , the way it goes during confirm sales order or picking list or invoice. I am looking for particular method call where I can just pass my sales id and it checks the credit limit and send SO to credit management hold if it doesn't follow the check.  I have attached the code which I had already used.
  • Suggested answer
    DAnny3211 Profile Picture
    11,397 on at

    Hi,

     

    What you’re seeing typically happens when the credit‑management pipeline runs but no blocking rule actually triggers (or the checkpoint isn’t enabled for that stage). In Finance, a sales order is only added to the Credit management hold list when both are true: (1) the relevant credit‑management checkpoint is enabled for the document stage you’re checking, and (2) at least one blocking rule evaluates to “block.” Otherwise the runtime just evaluates and continues—no hold is created. [1][2]

     

    Configuration checks (do these first)

     

    1. Checkpoints are on for the stage you’re invoking (e.g., confirmation, packing slip, invoice, or your custom checkpoint). Go to Accounts receivable parameters ▸ Credit management and verify the Credit management checkpoint settings. [2]

    2. Blocking rules exist and are active for your scenario (credit‑limit used, days overdue, payment‑terms change, settlement‑discount change, etc.). Since 10.0.35, a credit check requires blocking rules; older behavior that checked without rules was fixed. If no rule blocks, nothing is written to the hold list. [1][3]

    3. Confirm you can see resulting holds at Credit and collections ▸ Credit management hold list. If you use workflow, the Credit management release workflow also surfaces the hold there. [4]


    4.  
     

    Code pattern\
    Your factory approach is on the right track. The base class is abstract; the factory returns a concrete controller for the document stage. The usual sequence is:

     

     

    CredManCreditControl cc =
        CredManCreditControl::newFromDocumentStatusCheck(CredManDocumentStatusCheck::Invoice); // choose the stage that matches your checkpoint
    
    cc.parmSalesTable(salesTable);
    
    // Evaluate rules for the selected stage
    cc.run();
    
    // If a blocking rule fired, create the hold record in the hold list
    cc.createCreditHold();
    

     

     

    If run() doesn’t create a block context (because no rule matches, the checkpoint is off, or exclusions release the order), createCreditHold() won’t insert anything—that’s by design. Validate by temporarily defining a blocking rule that always blocks (for a test customer or group) and re‑running the snippet. [1]

     

    Troubleshooting tips

     

    • Ensure you’re calling the correct document stage. If your button is meant to mimic the Invoice checkpoint, use the invoice stage; if it’s intended to behave like Confirm, switch the factory argument accordingly. The runtime evaluates rules per stage. [1]

    • Double‑check exclusions and release settings—an exclusion rule with “Release sales order” will bypass other rules. [1]

    • Verify Credit management is enabled in parameters (moved under Accounts receivable parameters in recent versions). [2]


    •  
     

    If this points you in the right direction, please validate the reply on the thread so others can find it more easily.

     

    Thanks and best regards,\
    Daniele\
    Note: This response was prepared with support from Copilot to ensure clarity and completeness.


    References
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at
     
    An easy way to find it is using debugger, If you can setup the breakpoint and make a customer violate credit limit, that would show you the stack trace.
     
    when we asked you about the button, we wanted to know where do you click to check the credit limit?
  • spidey1010 Profile Picture
    183 on at
    Hi Shoaib,
    Obviously I had debugged, and as per the call stack only I was able to get the code which I have posted. Moreover the button for now is confirm sales order. On the click of it , it checks  the credit managment check too.  So that's the button
  • spidey1010 Profile Picture
    183 on at
    Hi  ,
    If you see I had already used the same approach of creating the holds which you mentioned, but it did not succeed.
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at
     
    What is the setup of your customer credit check. I have checked the stack trace with following setup and it never goes to the classes you mentioned. 
     
     
     
    [External Code]    
         Dynamics.AX.ApplicationSuite.31.netmodule!Dynamics.AX.Application.CustCreditLimit.`showErrorMsg(decimal _balanceInvoiced, decimal _balanceCurrentOrder) Line 1283    C#
         [External Code]    
         Dynamics.AX.ApplicationSuite.31.netmodule!Dynamics.AX.Application.CustCreditLimit.`checkGivenBalances(decimal _balance, decimal _orderBalance) Line 829    C#
         [External Code]    
         Dynamics.AX.ApplicationSuite.31.netmodule!Dynamics.AX.Application.CustCreditLimit.`check() Line 797    C#
         [External Code]    
         Dynamics.AX.ApplicationSuite.31.netmodule!Dynamics.AX.Application.CustCreditLimit.`main(Dynamics.AX.Application.Args _args) Line 1419    C#
         [External Code]    
  • spidey1010 Profile Picture
    183 on at
    Hi Sohaib, 
    I checked the call stack on the confirm button of sales order. The setup of customer is  this- 
     
    And blocking rules-
     
     
  • spidey1010 Profile Picture
    183 on at
    In short, I want to achieve the credit management check functionality and if the credit limit has been exceeded then the credit hold should be created.

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

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
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans