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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Extending InventCostClosingRecalc (RunBaseBatch) to include new parameter - working but batch history incomplete

(0) ShareShare
ReportReport
Posted on by 506

In Inventory mgt > Periodic > Closing and adjustment there is the Recalculation function which I've been asked to customise so that on a daily batch the parameter "Recalculate inventory up to:" date is always today's date.

The request is that I add a checkbox directly below the date field and that (when checked) ignores the Period code or date supplied and sets the transaction date to today before running the calc (InventCostClosingRecalc).

I'm assuming that another "Period code" cannot be setup to cover this requirement but I've not looked at that a lot.

InventCostClosingRecalc extends InventCostClosing. To get the parameter to appear in the desired position I decided to extend InventCostClosing.

It seems to work ok (after Compiling forward of InventCostClosing) and I debugged the CIL batch code in VS to ensure the logic in run() is working.

But I have 2 questions...
1. Why, when you review the batch job history (Sys admin > Inquiries) clicking on View tasks and then Parameters, the parameter value of the checkbox is unchecked instead of being checked?
2. Why, when you click on Log in the same form, nothing happens but there is an error that is handled in the CIL? What should happen here? Not sure of the purpose of this Log button.


The main code changes are below because I think I must have missed something to get the above behaviour?

    class InventCostClosing extends RunBaseBatch
    {
        // ...
        DialogField dialogDateDefaultCheck;
        NoYesId useDefaultDate;

        // ...


        #DEFINE.CurrentVersion(7)

        #LOCALMACRO.CurrentList
        TransDate,
        Specification,
        ProdJournal,
        UpdateLedger,
        FreeTxt,
        MaxIterations,
        MinTransferValue,
        adjustmentType,
        cancelRecalculation,
        runRecalculation,
        collapseGroups,
        // <GEERU>
        periodCode,
        inventTransCurrency,
        // </GEERU>

        useDefaultDate

        #ENDMACRO

    }

    public Object dialog()
    {
        // ...
        dialogDateDefaultCheck = dialog.addField(extendedTypeStr(NoYesId), "Default date to batch date", "help text here");
        // ...
    }

    public boolean getFromDialog()
    {
        //...
        useDefaultDate = dialogDateDefaultCheck.value();
        //...
    }

    public void run()
    {
        // ...
        try
        {
            this.initTransDate(false);

            if(useDefaultDate)
            {
            transDate = systemDateGet();
            }
        // ...
    }

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi,

    Did you increment the CurrentVersion when you added the new parameters? If the original code had it at 7, please try incrementing it to 8 and check if you are able to see the parameter checked?

    As for the error, I am not sure. Can you check running the job once without having the debugger on and see if the error is available in the Log?

  • _MGP Profile Picture
    506 on at

    Thanks for the reply.. I'd just forgotten to capture the value of the packed/unpacked variable and display it in the dialog method...

    Not sure about the error that runs when you click Log ... it's being handled at least and everything seems to work ok now.

     public Object dialog()
        {
            // ...
            dialogDateDefaultCheck = dialog.addField(extendedTypeStr(NoYesId), "Default date to batch date", "help text here");

            dialogDateDefaultCheck.value(useDefaultDate);
            // ...
        }

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi _MGP,

    Instead of writing two statements, you can try this -

    dialogDateDefaultCheck = dialog.addFieldValue(extendedTypeStr(NoYesId), useDefaultDate, "Default date to batch date", "help text here");

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 460 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans