Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Get Form Header Data i...
Finance forum
Unanswered

Get Form Header Data in Batch Job Contract using X++

Posted on by 490
Business Requirement:
 
On Inventory Movement Journal Header form , there is some logic  based on that I have to create journal lines based on some values in Header table i.e, InventJournalTable , but i want to process this using a batch , So how can i get  header jounal ID or Recid , and process this to add lines using Sysoperation framework
 
 
  • Anton Venter Profile Picture
    Anton Venter 18,524 Super User 2024 Season 2 on at
    Get Form Header Data in Batch Job Contract using X++
    Hello,
     
    From the main method, I usually do something like this on the Key field of the table. You can then use the query in SysOperation class method and it will only contain the one record. This example is based on CustTable.
     
    public void modifyQueryFromArgs(Args _args)
    {
        CustTable custTable = _args.record();
        
        if (custTable)
        {
            MyContact contract = this.getDataContractObject(); // Todo: change contract type to your own.

            if (contract)
            {
                Query query = contract.getQuery();

                if (query)
                {
                    QueryBuildDataSource custTable_ds = query.dataSourceTable(tableNum(CustTable));
                    
                    SysQuery::findOrCreateRange(custTable_ds, fieldNum(CustTable, AccountNum)).value(
                        queryValue(custTable.AccountNum));
                    
                    contract.setQuery(query); // Replace query in contract with modified query.
                }
            }
        }
    }
     
  • Layan Jwei Profile Picture
    Layan Jwei 7,071 Super User 2024 Season 2 on at
    Get Form Header Data in Batch Job Contract using X++
    Hi Sachin,
     
    So what's ur issue exactly? can you please show us the code u did so far and where are you stuck?
  • Sachin Mittal Profile Picture
    Sachin Mittal 490 on at
    Get Form Header Data in Batch Job Contract using X++
    It will be one time batch only , and in contract of batch job it should show journal ID from which we open the batch , we add a menu item in action pane and on opening it gets header Journal ID as parameter in contract
     
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,532 Super User 2024 Season 2 on at
    Get Form Header Data in Batch Job Contract using X++
    Hi Sachin,
     
    Can you clarify if a journal ID should be determined automatically in the batch job execution, or should a user fill the journal as parameter value for the batch job? IS the requirement to have a one-time only or recurring batch job?

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans