web
You’re offline. This is a read only version of the page.
close
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);

    
}

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at
    [deleted]
  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    RunBaseBatch handles the previously used values by the #CurrentList macro, and pack/unpack methods.  Check class Tutorial_RunBaseBatch, it is a working example.

    I don't understand how your form and class are related. But if you don't need your code to work in batch, you could just launch the form from run method of your class. This way the form gets the current instance of your class, and can access the variables there.

  • Mav Profile Picture
    on at

    Thanks for your note. please note  that

    Form DS is tmptable, init () of this form calls myclass.populatetmptable()  which populates this tmptable.

    When i make following changes to form init () & myCustomClassPopulateTmpTable() after which i can use the date values in my populateTMPMethod, but this is hardcoded , i think if there is a way i can pass dialog date values to form init level then atleast issue #2 can be resolved.

    Code Changes made (hardcoded to test if it works)

    FORM
    public void init()
    {
    
     TransDate fromDate,toDate,payRollDate;
    
    
    MyCustomClass myCustomClass = new MyCustomClass();
    
    fromDate = dateNull();
    toDate = dateNull();
    payRollDate = 18\09\2020;
    
    super();
    
    myTmpTable = myCustomClass.populatemyTmpTable(fromDate,toDate,payRollDate);
    MYTmpTable.linkPhysicalTableInstance(myTmpTable);
    
    
    }
    
    
    MYCUSTOMCLAAS
    
    
    public MyTmpTable populatemyTmpTable(_fromDate,_toDate,_payRollDate)
    {
    
    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 
    
    }

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    I can't add anything to my previous reply, just asking you to read it again. It contains the solution for you.

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Can you now see the previous values on the dialog?

    Let's focus on that first. After that we can focus on how to pass those values to your form. Ok?

  • Verified answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    Your fields have no values because you don't set any. The system automatically loads last values (if you implement packing correctly), but in RunBase framework, it's up to you to use them. (The SysOperation framework does that automatically.)

    Do it in dialog(). For example, replace

    dlgFromDate = dialog.addField(extendedTypeStr(TransDate),"@SYS5209");

    with

    dlgFromDate = dialog.addFieldValue(extendedTypeStr(TransDate), fromDate, "@SYS5209");

  • Mav Profile Picture
    on at

    I agree.

    While checking i can see that my pack/unpack & macros in class declaration is same as that tutorial, however unlike tutorial my dialog does not relaunch with previous values , still checking on this.

  • Mav Profile Picture
    on at

    Declaration of macros in class declaration along with pack & Unpack are coded in same way as that tutorial.

    However in my case i do not see the previous values unlike the tutorial, is there any other method i need to check ?

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    I assume you already saw Martin's reply above. Was it helpful? Could you please share your current code?

  • Mav Profile Picture
    on at

    Thanks Martin & Nikolaos , i can now see previous values in my dialog

    COuld you please help in solving the issue where i want these dialog values to go to form at init level like mentioned above.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans