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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Using Tmp table of form in batch job class x++

(0) ShareShare
ReportReport
Posted on by 163
I created a new form with temp tables data source , I need to use all of temp tables in select statement but when I select any of them it doesn't has any data . 
How can I use them ?
//
 
this is my form I need when I clicked on Ok button to call batch job class and loop on all temp tables 
there is any way to do this ?
I have the same question (0)
  • Martin Dráb Profile Picture
    236,972 Most Valuable Professional on at
    Using Tmp table of form in batch job class x++
    It means that you have a bug in code; most likely you're using a wrong (empty) buffer. Unfortunately I can't comment on details of your code because you told us nothing about it.
  • Menna Allah Ahmed Profile Picture
    163 on at
    Using Tmp table of form in batch job class x++
      public void clicked()
            {   
                
              
                    Args args = new Args();
                    args = element.args();
                   ImportCategoryBatchCFM::main(args);
                super();
    
               }  
    this code if clicked button on my form 
  • Menna Allah Ahmed Profile Picture
    163 on at
    Using Tmp table of form in batch job class x++
        public static void main(Args args)
        {
            ImportCategoryBatchCFM _ImportCategory = new ImportCategoryBatchCFM();
         
            if (! args || ! args.record())
            {
                throw error(strFmt("@SYS29104", classStr(ImportCategoryBatchCFM)));
            }
            formRun SetUpForm = classFactory.formRunClass(args);
    
            CategoryContractTmpCFM CategoryContractTmpCFMobj;
            select * from CategoryContractTmpCFMobj ;
    
           FormRun ContractForm = args.caller();
            if (SetUpForm)
            {
                ProjInvoiceTable ProjInvoiceTable = SetUpForm.args().record();
                _ImportCategory._parmProjInvoiceTable(ProjInvoiceTable);
               CategoryContractTmpCFM CategoryContractTmpCFM = SetUpForm.ParmCategoryContractTmpCFM();
               _ImportCategory.runOperation();
    
            }
        }
    this main of batch class 
    CategoryContractTmpCFMobj  is empty buffer 
  • Martin Dráb Profile Picture
    236,972 Most Valuable Professional on at
    Using Tmp table of form in batch job class x++
    Yes, categoryContractTmpCFMobj doesn't contain any records. You declared a new temporary buffer in main() and didn't insert any data to it, therefore it can't contain any data. It has nothing to do with the in your form.
     
    If you want data from the form, you need to get the buffer used by the form data source used by the form. You have the form in contractForm variable. Then you can use SysFormDataSource::findDataSource(), for example, to find the data source, and cursor() to get the buffer from the data source.

    Also note that you can't simply refer to a temporary buffer from a batch, because such a memory location with the data won't exists on a batch server. You need to serialize the data in some way.
  • Menna Allah Ahmed Profile Picture
    163 on at
    Using Tmp table of form in batch job class x++
    I need to loop on all records doesn't need one record 
  • Martin Dráb Profile Picture
    236,972 Most Valuable Professional on at
    Using Tmp table of form in batch job class x++
    Yes, I understand you want multiple records. You'll use a select statement to fetch the records you want, the difference is that you'll query a buffer that actual contains data, instead of an empty buffer.
     
    It seems that you have little idea about how to use temporary tables and you'll make your job much easier if you learn the basics. For example, this article may give you a lot of important information.
  • Menna Allah Ahmed Profile Picture
    163 on at
    Using Tmp table of form in batch job class x++
    I tried your solution now also no data selected (datasource of cursor )
     
     formRun SetUpForm = classFactory.formRunClass(args);
    I got formRun by this way beacause args.caller () saw the caller of my form not my form so Is it right or not ?
     
  • Martin Dráb Profile Picture
    236,972 Most Valuable Professional on at
    Using Tmp table of form in batch job class x++
    This code makes no sense at all. By classFactory.formRunClass(), you created a new empty form, which has absolutely no data and therefore it's useless for you. What you want is the form instance where you added the data.
     
    If args.caller() contains a wrong object, you have problem either in how you're calling your class or in your expectations. If you need our help, you'll need to give us more information about your solution.
  • Menna Allah Ahmed Profile Picture
    163 on at
    Using Tmp table of form in batch job class x++
    I already show you my code , I call class by classobj::main(element.args()) 
    so in batch class how can I get formRun 
  • Martin Dráb Profile Picture
    236,972 Most Valuable Professional on at
    Using Tmp table of form in batch job class x++
    That's the bug. You aren't passing information about the current form - element.args() contains information about how the form was called. These are the arguments that were passed to your form by its caller. You should learn to use the debugger, because it can show you things like these.
     
    The best approach will be throwing this code away and using a menu item button. It means that you don't need any code at all, so you also can't introduce any bugs, it'll make security setup much simpler and do on.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 582 Most Valuable Professional

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 542

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans