5/17/2021

Axapta 2009 : Axapta สร้าง List Department ให้เลือก จาก Dimension Group

 Axapta 2009 : Axapta สร้าง List Department ให้เลือก จาก Dimension Group
If you want to use a particular dimension as a dialog field in Dynamics AX 2009 (or earlier versions), you can create your own Extended Data Type (derived from Criterias) as described below. The decisive factors are the relations of this EDT.

In the example, the cost center is to be offered as a dialog field.

Create Dialog
  1. protected Object dialog(DialogRunbase dialog, boolean forceOnClient)
  2. {
  3.     Object ret;
  4.     ret = super(dialog, forceOnClient);
  5.     df_project = ret.addField(TypeId(DimensionACEdit));
  6.     return ret;
  7. }


Button Edit Show Dialog
Code In GL Edit Department AC
  1. void clicked()
  2. {
  3.     //LedgerJournalTrans_ds.allowEdit(true);
  4.     Dialog              myDialog;
  5.     DialogField         myDialogFieldDepartment;
  6.     LedgerJournalTrans  myLedgerJournalTrans;
  7.     LedgerJournalTrans  LedgerJournalTransUpdate;
  8.     ;
  9.  
  10.     super();
  11.     myLedgerJournalTrans = ledgerJournalTrans_ds.cursor();
  12.  
  13.     myDialog = new Dialog("Department Edit.");
  14.     myDialogFieldDepartment = myDialog.addFieldValue(typeId(DimensionACEdit), '', "void clicked()
  15. {
  16.     //LedgerJournalTrans_ds.allowEdit(true);
  17.     Dialog              myDialog;
  18.     DialogField         myDialogFieldDepartment;
  19.     LedgerJournalTrans  myLedgerJournalTrans;
  20.     LedgerJournalTrans  LedgerJournalTransUpdate;
  21.     ;
  22.  
  23.     super();
  24.     myLedgerJournalTrans = ledgerJournalTrans_ds.cursor();
  25.  
  26.     myDialog = new Dialog("Department Edit.");
  27.     myDialogFieldDepartment = myDialog.addFieldValue(typeId(DimensionACEdit), '', "Departmaint :");
  28.  
  29.     if(myDialog.run()){
  30.         //if(box::yesNo("Press 'Yes' to Confirm / Press 'No' to Cancel", DialogButton::No, "Please select...") == DialogButton::Yes){
  31.             ttsbegin;
  32.                 SELECT FORUPDATE * FROM LedgerJournalTransUpdate
  33.                 WHERE LedgerJournalTransUpdate.RecId == myLedgerJournalTrans.RecId;
  34.                 {
  35.                     LedgerJournalTransUpdate.DimensionACEdit[1] = myDialogFieldDepartment.value();
  36.                     LedgerJournalTransUpdate.update();
  37.                     LedgerJournalTrans_ds.reread();
  38.                     LedgerJournalTrans_ds.refresh();
  39.                 }
  40.             ttscommit;
  41.         //} //Close If.
  42.     } //Close If.
  43. }:");
  44.  
  45.     if(myDialog.run()){
  46.         //if(box::yesNo("Press 'Yes' to Confirm / Press 'No' to Cancel", DialogButton::No, "Please select...") == DialogButton::Yes){
  47.             ttsbegin;
  48.                 SELECT FORUPDATE * FROM LedgerJournalTransUpdate
  49.                 WHERE LedgerJournalTransUpdate.RecId == myLedgerJournalTrans.RecId;
  50.                 {
  51.                     LedgerJournalTransUpdate.DimensionACEdit[1] = myDialogFieldDepartment.value();
  52.                     LedgerJournalTransUpdate.update();
  53.                     LedgerJournalTrans_ds.reread();
  54.                     LedgerJournalTrans_ds.refresh();
  55.                 }
  56.             ttscommit;
  57.         //} //Close If.
  58.     } //Close If.
  59. }
ตัวอย่าง : https://www.schweda.net/blog_ax.php?bid=555&wdl=en

No comments:

Post a Comment