Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

adding a temp table to to form

Posted on by 5

Hello team,

I'm trying to display a temp table that I have added to the data source of a form. The temp table has three fields that I want to display  

in the grid of the form.  I'm using a class 'rtiFillDueDateBeforeInvoiceTemp to fill the temp table like this: 

'

public class rtiFillDueDateBeforeInvoiceTemp
{
CustInvoiceJour custInvoiceJour ;

DueDateBeforeInvoiceTmp dueDateBeforeInvoiceTmp ;

}

public DueDateBeforeInvoiceTmp fillTmpData()
{
ttsbegin;
while select custInvoiceJour

where custInvoiceJour.DueDate < custInvoiceJour.InvoiceDate

{

dueDateBeforeInvoiceTmp.InvoiceId = custInvoiceJour.InvoiceId;
dueDateBeforeInvoiceTmp.DueDate = custInvoiceJour.DueDate;
dueDateBeforeInvoiceTmp.InvoiceDate = custInvoiceJour.InvoiceDate;

dueDateBeforeInvoiceTmp.insert();

//insertList.add(tmpInventTable);

}

//insertList.insertDatabase();
ttscommit;
return dueDateBeforeInvoiceTmp;


}

and this is my init method in the form : 

public class FormRun extends ObjectRun
{

CustInvoiceJour custInvoiceJour ;

DueDateBeforeInvoiceTmp dueDateBeforeInvoiceTmp ;

rtiFillDueDateBeforeInvoiceTemp rtiFillDueDateBeforeInvoiceTemp;

}

public void init()
{
super();

// dueDateBeforeInvoiceTmp.setTmpData(dueDateBeforeInvoiceTmp ::getTmpData());

rtiFillDueDateBeforeInvoiceTemp = rtiFillDueDateBeforeInvoiceTemp::construct();




//   rtiFillDueDateBeforeInvoiceTemp.fillTmpData();

dueDateBeforeInvoiceTmp.setTmpData(rtiFillDueDateBeforeInvoiceTemp.fillTmpData());

}

and when I try to open the form, it is showing an empty grid with no records. Someone can help me with this?

Best ragards, 

  • OussamaF Profile Picture
    OussamaF 5 on at
    RE: adding a temp table to to form

    Yes

    You are right

    Thank you

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: adding a temp table to to form

    Great! Please mark the helpful answer(s) as Verified, which is done by choosing Did this answer your question > Yes.

  • OussamaF Profile Picture
    OussamaF 5 on at
    RE: adding a temp table to to form

    Thanks it works

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: adding a temp table to to form

    I see you put a data to a variable, not to the data source. It seems that your variable gets successfully populated, but it has nothing to do with what's displayed in the form.

    Remove dueDateBeforeInvoiceTmp variable from your form and use the name of your form data source instead.

    By the way, what it the reason for using a temporary table? You could apply the filter (DueDate < InvoiceDate) directly to CustInvoiceJour used as a form data source.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: adding a temp table to to form

    Hi OussamaF,

    You have declared the temp Table in the class declaration, which you won't need. You should have this table in the form data source as well which you can use. If the name of the data source is DueDateBeforeInvoiceTmpDS, for an example, your init method will look Like this -

    public void init()
    {
        super();
    
       rtiFillDueDateBeforeInvoiceTemp = rtiFillDueDateBeforeInvoiceTemp::construct();
       
       dueDateBeforeInvoiceTmpDs.setTmpData(rtiFillDueDateBeforeInvoiceTemp.fillTmpData());
        
    
    }

  • OussamaF Profile Picture
    OussamaF 5 on at
    RE: adding a temp table to to form

    Hey Martin,

    I'm using an in-memory temp table.

    When I'm debugging, it's going through the loop that is supposed to fill the temp table, then the temp table is returned where it is called in the init() method form.

    but when I open the form it's showing an empty grid with no records.

    here is my code in the form  :

    public class FormRun extends ObjectRun
    {
    
        CustInvoiceJour custInvoiceJour  ;
        DueDateBeforeInvoiceTmp  dueDateBeforeInvoiceTmp  ;
        rtiFillDueDateBeforeInvoiceTemp  rtiFillDueDateBeforeInvoiceTemp;
    
    
    }
    public void init()
    {
        super();
    
       rtiFillDueDateBeforeInvoiceTemp = rtiFillDueDateBeforeInvoiceTemp::construct();
       
       dueDateBeforeInvoiceTmp.setTmpData(rtiFillDueDateBeforeInvoiceTemp.fillTmpData());
        
    
    }
    
    

    and that's my code in the class that has the filling temp table method 

    public class rtiFillDueDateBeforeInvoiceTemp
    {
        CustInvoiceJour custInvoiceJour  ;
        DueDateBeforeInvoiceTmp  dueDateBeforeInvoiceTmp  ;
    
    }
    
    public  DueDateBeforeInvoiceTmp fillTmpData()
    {
        
       //  RecordInsertList insertList = null;
        // insertList = new RecordInsertList(tablenum(DueDateBeforeInvoiceTmp));
    
        
        ttsbegin;
         while select  InvoiceId, DueDate, InvoiceDate from custInvoiceJour
    
            where custInvoiceJour.DueDate < custInvoiceJour.InvoiceDate ;
    
        {
    
                dueDateBeforeInvoiceTmp.clear(); 
                dueDateBeforeInvoiceTmp.InvoiceId = custInvoiceJour.InvoiceId;
                dueDateBeforeInvoiceTmp.DueDate =  custInvoiceJour.DueDate;
                dueDateBeforeInvoiceTmp.InvoiceDate = custInvoiceJour.InvoiceDate;
    
                dueDateBeforeInvoiceTmp.insert();
    
          //   insertList.add(dueDateBeforeInvoiceTmp);
    
        }
    
       //  insertList.insertDatabase();
        ttscommit;
        return dueDateBeforeInvoiceTmp;
    
    
    }

    This is what is showing : 

    DueDateFormGridEmpty.PNG

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: adding a temp table to to form

    Which type of temporary table are you using?

    What did you find when you debugged your code?

    Also, please post your code with line indentation - it'll be much easier to read for us. Use Insert > Code (in the rich formatting view) to paste your code.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans