form etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
form etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

26 Ocak 2021 Salı

AX 2012 - Send filter with args

 

If your filter just one record, you can run filter with args.record(). In the other case if you have to filter more than one record, you can't use record method. You can use InitialQueryParameter for this:

            Args                 args = new Args();
            MenuFunction         MenuFunction = new MenuFunction('LedgerJournalTable', MenuItemType::Display);
            Query                q = new Query();
            QueryBuildDataSource QBDS = q.addDataSource(tableNum(LedgerJournalTable));

            if (ABCRCreditTable.AccualJournalNum != "")
                QBDS.addRange(fieldNum(LedgerJournalTable,JournalNum)).value(ABCRCreditTable.AccualJournalNum);
            if (ABCRCreditTable.AccualJournalNum2 != "")
                QBDS.addRange(fieldNum(LedgerJournalTable,JournalNum)).value(ABCRCreditTable.AccualJournalNum2);

            args.initialQuery(InitialQueryParameter::createByQuery(q));
            args.caller(this);

            MenuFunction.run(args);  



18 Ocak 2019 Cuma

AX 2012 - Change backcolor for Test/Dev/per company

Yo can write something like this to Run method of SysSetupFormRun class:

 this.design().colorScheme(FormColorScheme::RGB);
 this.design().backgroundColor(WinAPI::RGB2int(71,216,86));


or you can write a switch/case with curext() function.

14 Kasım 2017 Salı

AX 2012 - Add InventDim to Form Grid

Add InventDim table to data source, than make InnerJoin with table which inventDimId field used (in this sample table name is SNBProductDemonte).

Add a Group control like this at the grid:




Add this code to form:

public class FormRun extends ObjectRun
{
    InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;
}
public void init()
{
    super();
    ...
    element.updateDesign(InventDimFormDesignUpdate::Init);
...

}

Object inventDimSetupObject()
{
    return inventDimFormSetup;
}

void updateDesign(InventDimFormDesignUpdate mode)
{
   InventDimParm inventDimParmVisible;

    switch (mode)
    {
        // Form Init
        case InventDimFormDesignUpdate::Init    :
            if (!inventDimFormSetup)
                inventDimFormSetup  = InventDimCtrl_Frm_EditDimensions::newFromForm(element);
                inventDimFormSetup.parmSkipOnHandLookUp( true);

                // Use the methods on InventDimParm
                // to set which dimensions to show when form is initialized
         //       inventdimparmvisible.inventsiteidflag       = true;
           //     inventdimparmvisible.InventLocationIdFlag   = true;
                inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmVisible);

        // Datasource Active
        case InventDimFormDesignUpdate::Active  :
            inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(SNBProductDemonte.ItemId)); 
            inventDimFormSetup.formSetControls( true);
            break;

        // Datasource Field change
        case InventDimFormDesignUpdate::FieldChange :
            inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(SNBProductDemonte.ItemId)); 
            InventDim.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled()); // InventDim is referring to datasource name
            inventDimFormSetup.formSetControls( true);
            break;

        default :
            throw error(strFmt ("@SYS54195", funcName()));
    }
}

Add this code to table which InventDimId field:

public boolean validateWrite()
{
    boolean ret;

    SNBProductDemonte.InventDimId = InventDim::findOrCreate(InventDim).InventDimId;
    ret = super();
  
    return ret;
}

public int active()
{
    int ret;
    ret = super();

    element.updateDesign(InventDimFormDesignUpdate::Active);
    return ret;
}

Add this code to modified method of ItemId field:

public void modified()
{
    super();

    element.updateDesign(InventDimFormDesignUpdate::FieldChange);
    InventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
}


Add InventDimParmFixed Display menu item from AOT to form.

Source:
https://daxbeginners.wordpress.com/2014/08/05/how-to-dynamically-display-inventory-dimension/

12 Kasım 2015 Perşembe

AXAPTA - Add extra action to info function with SysInfoAction class

There're two ways to call a form with this class:

info(strfmt("Sales order created: %1",salesTable.SalesId),"",
            SysInfoAction_TableField::newBuffer(salesTable));


Difference with this way with up is while this way sends record data to form, upper way doesn't:

SysInfoAction_FormRun    infoAction = SysInfoAction_FormRun::newFormName(formStr(SalesTable));
;
infoAction.parmCallerBuffer(salestable);
 

info(strfmt("Satış siparişi oluşturuldu: %1",salesTable.SalesId),"",
            infoaction);

16 Ekim 2015 Cuma

AXAPTA - Pack-unpack at forms

ClassDeclaration method:

    Container   packedQuery;
    SysQueryRun qRun;
    s
tr dummy;
    #DEFINE.CurrentVersion(1)
    #LOCALMACRO.CurrentList
        dummy,
        packedQuery
    #ENDMACRO


Other methods:

container pack()
{
    ;
    dummy      = txtDummy.valuestr();
    return [#CurrentVersion,#CurrentList];
}


public boolean unpack(container _packedClass)
{
    int version = conPeek(_packedClass,1);

    switch (version)
   {
        case #CurrentVersion:
            [version,#CurrentList] = _packedClass;
            break;
        default:
            return false;
    }
    return true;
}


public void init()
{
    ;
    xSysLastValue::getLast(this);
    super();
    txtDummy(dummy);
    element.initQuery();
}


public void close()
{
    super();
    xSysLastValue::saveLast(this);
}


void initParmDefault()
{
}


private IdentifierName lastValueDesignName()
{
    return '';
}


private IdentifierName lastValueElementName()
{
    return this.name();
}


private UtilElementType lastValueType()
{
    return UtilElementType::Form;
}


private UserId lastValueUserId()
{
    return curuserid();
}


public dataAreaId lastValueDataAreaId()
{
    return curExt();
}


This method is not mandatory, but you may write like this if you would like to use query:


void initQuery()
{
  Query                q;
  QueryBuildDataSource qbds;
  QueryBuildDataSource qbds2;
  QueryBuildRange      qRange;
  ;
  if (packedQuery)
      qRun = new SysQueryRun(packedQuery);
  else
  {
      q = new query();
      qbds = q.addDataSource(tablenum(EmplTable));
      qRun = new SysQueryRun(q);
  }
  qRun.promptLoadLastUsedQuery(false);
}


This one is for select button of query, so of course not mandatory too:

 void clicked()
{
    ;
    super();
    if (qRun.prompt())
        packedQuery = qRun.pack();
}

2 Eylül 2014 Salı

AX 2012 - Add splitter to form

It's more easy to add splitter control to AX 2012 than 2009. I'll tell horizontal splitter:


Add a group for top part of form. I named it as Hsplitter. Set AutoDeclaration = Yes and  Style = SplitterHorizontalContainer. Add another group for down part of form. Give a name to top group. I named it as TopGroup, also set AutoDeclaration = Yes for this group too. Make bottom groups Height as Column Height. Splitter group should be betwen of other two.

Add this line to form's classDeclaration:

SysFormSplitter_Y                       HorizontalSplitter;

If splitter will be vertical should be SysFormSplitter_X.

Add this line to form's init method:

HorizontalSplitter = new SysFormSplitter_Y(HSplitter,TopGroup, element);

If vertical, should be new SysFormSplitter_X ...

That's all...

5 Ağustos 2014 Salı

AX 2012 - Add defaultdimension control to form

You can look for LedgerJournalTable form for how to do.
Add a relation with DimensionAttributeValueSet table's RecId  field for which field added from DimensionDefault EDT.

Add a tab page named tabFinancialDimensions and change properties like below:

AutoDeclaration = true
caption = @SYS101181
HideIfEmpty = No
NeedPermission = Manual

Add this line to forms classDeclaration method:

DimensionDefaultingController       dimensionDefaultingController;

Add this code part to forms init method:

public void init()
{

   boolean allowEdit = true;
    super();
    dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true, allowEdit, 0, this, tabFinancialDimensions, "@SYS101181");
    dimensionDefaultingController.parmAttributeValueSetDataSource(MyTable_ds, fieldStr(MyTable, DefaultDimension));
    dimensionDefaultingController.parmValidateBlockedForManualEntry(true);
}


Add this method to tab page:

public void pageActivated()
{
    dimensionDefaultingController.pageActivated();
    super();
}


Update table data source methods like below:

public void delete()
{
    super();
    DimensionDefaultingController.deleted();
}

public void write()
{
    ttsBegin;
    DimensionDefaultingController.writing();
    super();
    ttsCommit;
}

public int active()
{
    int ret;

    ret = super();
    DimensionDefaultingController.activated();
    return ret;
}


28 Kasım 2013 Perşembe

AXAPTA - Drop-down to table's container field at form

public void dropFile(str _FileName)
{
    BinData p = new BinData();
    ;
    super(_FileName);
    p.loadFile(_FileName);
    PRTSecondHandTractorStock.Picture = p.getData();
    element.redraw();
}

22 Temmuz 2013 Pazartesi

AXAPTA - Setfocus to a specified control when opening form

Should write a setfocus for control at form's firstField method:

public void firstField(int _flags=1)
{
    super(_flags);
    EmplId2.setFocus();
}

4 Haziran 2012 Pazartesi

Hide lookup button for a form control

Hide lookup button for a form control:

 DSerial.lookupButton(FormLookupButton::Never);

5 Aralık 2011 Pazartesi

AXAPTA when there isn't go to main table form menu item?

You can see at right click "Go to main table form" if current control bounded a tables key field. But if it's just created with extended data type, you cannot see this menu item.

I used Fatih Demirci'nin this code:

public void jumpRef()
{
EmplTable emplTable;
Args args;
MenuFunction menuFunction;
;
emplTable = EmplTable::find(this.text());
if (!emplTable)
{
return;
}
args = new Args();
args.caller(element);
args.record(emplTable);
menuFunction = new MenuFunction( menuitemdisplaystr(EmplTable),
MenuItemType::Display);
menuFunction.run(args);
}

But actually this code behaves different from systems default "Go to main table" menu item. It just filter related record. Orijinal menu item just locate related record not filter. After a little search I wrote this code. It works just like original:

public void jumpRef()
{
CustTable custTable;
Args args;
MenuFunction menuFunction;
;
args = new Args();
args.caller(element);
args.lookupfield(FieldNum(CustTable,AccountNum));
args.lookupValue(this.text());
menuFunction = new MenuFunction(MenuItemDisplayStr(custTable),MenuItemType::Display);
menuFunction.run(args);
}

2 Aralık 2011 Cuma

AXAPTA Create new record at another form and return from

Sometimes you can want to or have to create new record  at another form. There are some Axapta forms do it with complex ways. I couldn't understand Axapta's ways.
This is mine simple way:

Main forms data source create method:


public void create(boolean _append = false)
{
    Args                args;
    FormRun             formCreate;
    ;

        args = new Args();
        args.name(formstr(B_ExpressServiceNew));
        args.caller(element);
        formCreate = classfactory.formRunClass(args);
        formCreate.init();
        formCreate.run();
        formCreate.wait();
}

B_ExpressServiceNew, is my new record forms name.
This part should write at new record forms new record method:


    if (element.args() && element.args().caller() && element.args().caller().name() == formstr(B_ExpressService))

    {
     mainForm = element.args().caller();
     mainForm.SetRecord(oTable);
    }


B_ExpressService is my main form, oTable is my new record.
Setrecord method at main form for locate new record:

void SetRecord(SMAServiceOrderTable _order)
{
    ;
    SMAServiceOrderTable.reread();
    SMAServiceOrderTable.data(_order);
    SMAServiceOrderTable_DS.setCurrent();

} 

29 Kasım 2011 Salı

AXAPTA get value sent by "Goto Main Table Form" button.


This blog copy of my turkish blog in english. I created this because unfortunately Google translator is so terrible with turkish translates even mines... :)
This value accessible by args().record() method, but in case of calling from different table fields extended by, it's a bit hard. You have to put case for every caller table or:


FormStringControl   callerControl   = SysTableLookup::getCallerStringControl(element.args());
;
info(callercontrol.text());



I found this code part from Yakup Kirisci's blog. It just already from standart forms, but I didn't know until see his blog. It worked good for me. Thanks to him...