Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Running dialog based on runbase with previous values

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

I have a very similar requirement for a dialog like in class HCMDueCertificateUI builder which extends from SrsReportDataContractUIBuilder, however my dialog is in myCustomClass which extends from Runbase.

So i tried mimicking the code as much as possible.

Requirement are the following.

1.Present user with option to use date range or a specific date in dialog

2.Whnever dialog loads up it initialize with last used values

3.myCustomClass has populateTmpTable method  which uses above dates in its query to populate tmp table, the poulate tmp table form at its init level calls this method .

Issue with current code

1. Do not see dialog loading with previous used values.

2. Whenever it goes at forminit level in call stack all dialog values become 0  ,most probably it has to do with me initiating new instance of myCustomClasss at form init level , pls suggest fix for fixing these 2 issues.

Code

Class declaration myCustomClass
     DialogField                     dlgFromDate,dlgToDate,dlgPayRollDate;
     MyTmpTable                      mytmptable;
     TransDate                       fromDate,toDate,payRollDate;
     DialogGroup                     mainGroup;
     DialogGroup                     dateRange;
     DialogGroup                     payRollDateGrp;

     #DEFINE.CurrentVersion(1)
     #LOCALMACRO.currentlist
     fromDate,
     toDate,
     payRollDate
     #ENDMACRO
     
public Object Dialog()
{
    FormButtonControl   commandButtonOK, commandButtonCancel;
    DialogRunbase dialog;

    #define.Raised3D(3)
    #define.OKButton('CommandButton')
    #define.CancelButton('CommandButtonCancel')
    #define.QueriesGroup('QueriesGroup')
    ;

    dialog = super();
    dialog.caption( 'Generate ');

    dialog.allowUpdateOnSelectCtrl(true);


    commandButtonOK = dialog.dialogForm().form().design().control(#OKButton);
    if (commandButtonOK)
    {
        commandButtonOK.helpText("@SYS57795");
    }

    commandButtonCancel = dialog.dialogForm().form().design().control(#CancelButton);
    if (commandButtonCancel)
    {
        commandButtonCancel.helpText("@SYP4889653");
    }

    mainGroup = dialog.addGroup("Choose date range or payroll date");

    dateRange = dialog.addGroup("@SYS41297", mainGroup);
    dateRange.frameOptionButton(FormFrameOptionButton::Radio);
    dlgFromDate = dialog.addField(extendedTypeStr(TransDate),"@SYS5209");
    dlgToDate = dialog.addField(extendedTypeStr(TransDate),"@SYS35904");

    payRollDateGrp = dialog.addGroup("Payroll date", mainGroup);
    payRollDateGrp.frameOptionButton(FormFrameOptionButton::Radio);
    dlgPayRollDate = dialog.addField(extendedTypeStr(TransDate),"Payroll date");

    return dialog;


}

public boolean getFromDialog()
{
    boolean ret;
    MyPeriodType             myPeriodType;
    FormGroupControl         PeriodTypeLocal;

   PeriodTypeLocal = dateRange.control();

    if (PeriodTypeLocal.optionValue())
    {
        myPeriodType = MyPeriodType::RangeBased;
        fromDate    = dlgFromDate.value();
        toDate      = dlgToDate.value();

    }
    else
    {
        myPeriodType = MyPeriodType::DateBased;
        payRollDate = dlgPayRollDate.value();
    }

    this.initializeFields();
    ret = super();

    return ret;
}

public void initializeFields()
{
    boolean isRangeBased;

    dateRange.optionValue(isRangeBased);
    payRollDateGrp.optionValue(!isRangeBased);

    if(payRollDateGrp.optionValue()==true)
    {
        dlgFromDate.value(dateNull());
        dlgToDate.value(dateNull());
    }

    if(dateRange.optionValue()==true)
    {
        dlgPayRollDate.value("");

    }


}

public MyTmpTable populatemyTmpTable()
{
 
    insert_recordset myTmpTable(fie names f1,f2,f3)
     select sum(amt),f1,f2,f3,f4 from myTmpTable
      group by  f1,f2,f3,f4
       where (myTmpTable.PayrollDate  == payRollDate ||(myTmpTable.PayrollDate  >= fromDate &&  myTmpTable.PayrollDate <=toDate))   // this is where my dialog date become criteria for inserting data into tmp table & while debugging it shows 0 even after choosing values in dialog 
       
}

FORM INIT METHOD

public void init()
{
   MyCustomClass myCustomClass = new MyCustomClass();

    super();
    

    myTmpTable = myCustomClass.populatemyTmpTable();
    MYTmpTable.linkPhysicalTableInstance(myTmpTable);

    
}

  • Verified answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: Running dialog based on runbase with previous values

    Try to pass element.args().record() in the linkPhysicalTableInstance() method.

  • Mav Profile Picture
    on at
    RE: Running dialog based on runbase with previous values

    Ok so did the following and still see no data , objective is to see all rows from the tmptable, definitley doing something majorly irractional sorry about that especially in 2nd part of getting tmptable to form.

    Also note that i have menuitem for this form which has DS as my tmptable , so should we use that menuitem args thing to open the form using that menuitem & poulating with data .

    1> Pass a reference to temporary table to the form

    public void Process()
    {
        Args  args;
        Formrun   formrun;
    
        
        myTmpTableBuffer1 = this.populatemyTmpTable();
        
    
        args = new Args(formStr(myCustomFormDSTmpTable));
        args.openMode(OpenMode::Auto);
        
        args.record(myTmpTableBuffer1);
        
        formRun = classfactory.formRunClass(args);
        formRun.init();
        formRun.run();
        formRun.wait();
    }

    2>When you have the temporary table buffer in your form, link it to a data source of the form. Use either setTmpData() (with InMemory table) or linkPhysicalTableInstance (with TempDB table).

    MYCUSTOMFORMDSTMPTABLE
    
    public void init()
    {
      
        super();
    
        MYTMPTABLE.linkPhysicalTableInstance();
    
    
    }

  • Verified answer
    Martin Dráb Profile Picture
    231,895 Most Valuable Professional on at
    RE: Running dialog based on runbase with previous values

    First of all, you must pass a reference to the temporary table to the form. You have several options. For example, you can use args.record(mytmptable), or you can pass the whole myCustomClass through args.object(this) and then call myCustomClass's methods from the form.

    Or you can invert control - calling the form and letting the form to show the dialog. Because the form creates the object, it already has a reference and all it needs is calling a method returning the table.

    When you have the temporary table buffer in your form, link it to a data source of the form. Use either setTmpData() (with InMemory table) or linkPhysicalTableInstance (with TempDB table).

  • Mav Profile Picture
    on at
    RE: Running dialog based on runbase with previous values

    Yep I know that is the missing piece . Is there any out of box form method which I can override to accomplish this.

    can you share any sample/pseudo code pls.

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: Running dialog based on runbase with previous values

    You need code on your form to get the temp table from the class, and put it in the form data source. So that's the missing piece.

  • Mav Profile Picture
    on at
    RE: Running dialog based on runbase with previous values

    1>Can you share the code where you pass the temp table from your class to your form? Or is it not implemented yet?

    THis is same as shared earlier the populateTemptable() of my class return myTemptablebuffer after it is populated, I have attached this code again in code snippet below

    2>You need method in your class that returns the temp table. And you need to call that method from your form.

    Please share How & where should i call this method in my form 

    MYCUSTOMCLAAS
    public MyTmpTable populatemyTmpTable()
    {
     
        insert_recordset myTmpTable(fie names f1,f2,f3)
         select sum(amt),f1,f2,f3,f4 from myTmpTable
          group by  f1,f2,f3,f4
           where (myTmpTable.PayrollDate  == payRollDate ||(myTmpTable.PayrollDate  >= fromDate &&  myTmpTable.PayrollDate <=toDate))   // this is where my dialog date become criteria for inserting data into tmp table & while debugging it shows 0 even after choosing values in dialog 
           
           return myTmpTable;
    }
    
    public void Run()
    { 
    this.process();
    }
    public void Process()
    {
        Args  args;
        Formrun   formrun;
        
        this.populatemyTmpTable();
        
    
        args = new Args(formStr(myCustomTmpTableForm));
        args.openMode(OpenMode::Auto);
        formRun = classfactory.formRunClass(args);
        formRun.init();
        formRun.run();
        formRun.wait();
    }
    
    NO CODE AT FORM Level presently

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: Running dialog based on runbase with previous values

    Can you share the code where you pass the temp table from your class to your form? Or is it not implemented yet?

    You need method in your class that returns the temp table. And you need to call that method from your form.

    If you have further questions, please share your latest class code and form code. Thanks!

  • Mav Profile Picture
    on at
    RE: Running dialog based on runbase with previous values

    All variables seems to be correct. Also when i run while loop i can see tmptable values being displayed.

    How do i pass this tmptable values to my form which uses same tmptable for its grid , earlier i was doing this my linkphyscial instance at init level but due to change in design how do i get this accomplished now.

    public void Process()

    {

       Args  args;

       Formrun   formrun;

       this.populateMyCustomTmpTable();

       while select lMyCustomTmpTable

       {

           info(strFmt("%1 company ",MyCustomTmpTable.company));

       }

    ALL GOOD Till here

       args = new Args(formStr(myCustomTmpTableForm));

       args.openMode(OpenMode::Auto);

       formRun = classfactory.formRunClass(args);

       formRun.init();

       formRun.run();

       formRun.wait();

    Open the form but with blank values

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: Running dialog based on runbase with previous values

    I'm sorry, I don't understand your explanation. Can we take it one step at a time?

    1) First, please make sure that your class variables are correct before we move to the form. If you still have some doubts there, it's good to solve them now.

    2) Next, only once you are confident that your class variables are ok, let's move to the form. You already seem to launch it in a way that works. Then you can debug the population of the temp table and verify if it works correctly.

    3) And finally, once all previous parts are working, you can verify if you are passing the temp table to your data source in a correct way, so that the form can display the data.

    Is it ok like this? Waiting for your updates.

  • Mav Profile Picture
    on at
    RE: Running dialog based on runbase with previous values

    Ok so my class has run method which calls the process method & i dont need it to run in batcjh.

    Sp when i write below code in my process method i see the form opens but with no data in mytmptable which is ds of my form.

    Also i notice that payrolltoDate value shows up in the debugger ,ideally this value should be null as per my code in initializedFields() of my class  , apparently initialized fields does not get called or is working correctly failing which irrespective of what user chooses in dialig i will always get 3 values in debugger from to & payroll date , whereas intention is to only have 2 values if date range is selected which is from and to date OR  1 value payrolldate if only payroll is selected.

    pastedimage1602514422038v1.png

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,129 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,895 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans