Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Tuesday, July 9, 2013

Number Sequence in Dynamic AX (for Form level)

1. Create EDT
2. Use that EDT in the Table where it is required
3. Select the Class module which you going to implement this Number seq.
//Consider if we want for HRM then “NumberSeqModuleHRM” class is the target.
//Add below code in the loadModule()
            protected void loadModule()
     {
     NumberSeqDatatype datatype = NumberSeqDatatype::construct();
//Added by Alfasith
     datatype.parmDatatypeId(extendedtypenum(customerID));
//your EDT
     datatype.parmReferenceLabel(literalstr("RES-customerID"));
//Your label
     datatype.parmReferenceHelp(literalstr("RES-customerID"));
     datatype.parmWizardIsContinuous(true);
     datatype.parmWizardIsManual(NoYes::No);
     datatype.parmWizardIsChangeDownAllowed(NoYes::No);
     datatype.parmWizardIsChangeUpAllowed(NoYes::No);
     datatype.parmWizardLowest(1);
     datatype.parmWizardHighest(99999999);
     datatype.parmSortField(15);
//(This 15 is the next number that already in that default list)
     datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
    this.create(datatype);
    //code end
     }

4. Select the concern table. Create new methods as below
Here we take HRMParameters table 
// table on which that number seq is going to generate.

static client server NumberSequenceReference customer()
{
    return NumberSeqReference::findReference(extendedtypenum(customerID));//Your EDT name
}

5. Create a new job with the following code and run it:

static void NumberSeqLoadAll(Args _args)
{
NumberSeqApplicationModule::loadAll();
}

6. ( Control + W )
Select Organization administration-> Number Sequence-> Number Sequence
Select the module //here we select Human Resources
Select the EDT you created //Surly that EDT you created will be appear here.
Click GENERATE

7. Create a new job with the following code and run it:
static void NetvendNumberSeq(Args _args)
{
    NumberSeq  numberSeq;
    StudentID num;
    ;
    numberSeq = NumberSeq::newGetNum(VendParameters::student());
   
    num = numberSeq.num();
    info(num);
}

8. Select the Form on which that table is required.
Drop the table in to that form Data Source.

8(a). ClassDeclaration. Write the below code.

public class FormRun extends ObjectRun
{
    NumberSeqFormHandler numberSeqFormHandler;
}
/*************************************************************/
8(b). Create new method

NumberSeqFormHandler numberSeqFormHandler()
{
    if (!numberSeqFormHandler)
    {
       numberSeqFormHandler = NumberSeqFormHandler::newForm(NetRMSParameters::customer().NumberSequenceId,
                                                             element,
                                                             Table2_ds,
                                                             fieldNum(Table2, customerID)
                                                            );
    }
    return numberSeqFormHandler;
}

/***********************************************************/
8(c). Override the datasource methods of that table with following method in that form.
public void delete()
{
    ;
    element.numberSeqFormHandler().formMethodDataSourceDelete();
     super();
}
/***********************************************************/
public void write()
{
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();
}
/***********************************************************/
public void create(boolean _append = false)
{
    ;
    super(_append);
    element.numberSeqFormHandler().formMethodDataSourceCreate();
}

/***********************************************************/

Passing parameter between forms and Create reports using Multi select lookup

1.Create formA like
Note : FormA contains multiple select lookup so it has features of getting the multiple Account Number;
Main class is modified as below in the FormA




public class FormRun extends ObjectRun
{
    SysLookupMultiSelectCtrl msCtrl;
}
/***************************************************/
//in the init method of FormA.
public void init()
{
    super();
    // AccountNum - Name of control on which you want a lookup.
   // CustQry - Query to get the lookup data of that required table
    msCtrl = SysLookupMultiSelectCtrl::construct(element, AccountNum, querystr(CustQry));
}
/***************************************************************/
//in the button clicked() in FormA.

void clicked()
{
    // Args class is usually used in Axapta for passing parameters between forms
    Args            args;
    FormRun         formRun;
    container contain;
    str        containstr;
    ;

    args = new args();

    // Our values which we want to pass to FormB
    // If we want pass just simple string we can use 'parm' method of 'Args' class
    contain = [AccountNum.valueStr()];
    containstr = con2Str(contain);
    args.parm(containstr);

    // Run FormB

    args.name(formstr(CustomerDetails));
    formRun = classFactory.formRunClass(Args);
    formRun.init();
    formrun.run();
    formrun.wait();

    super();
}

/*******************************************************************/

2.Create FormB as like this



On clicking of the above FormA “Clickhere” that concern AccountNum details will be depicted in grid
//in the FormB Class declaration
public class FormRun extends ObjectRun
{
    container       contain;
    str CompanyId;
}
/*************************************************************************/
/ in the init() of that fornB
public void init()
{
    str             tmp;
    ;
    super();
    // Check for passed arguments
    if( element.args() )
    {
        contain = str2con(element.args().parm());
        //Now receive the container multiple value with separater as ";" to replace with ","
         AccountNumb.text(strReplace(strFmt("%1",conPeek(contain,1)),';',','));
    }
}
/**********************************************************/
In the Data source of the FormB drop the CustTable and in the executeQuerry() of that datasource
//This makes the grid to reflect with reference to the StringEdit that we added as the range to the grid.
public void executeQuery()
{
     this.query().dataSourceNo(1).addRange(fieldNum(CustTable,AccountNum)).value(AccountNumb.valueStr());
    super();
}
/***********************************************************/
3.Onclicking of “Cust report Generator” that concern report will be generated like this.



//here you find the change In the image that is because of the company image.


SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...