Wednesday, June 12, 2019

Date effective SimpleListDetails form with drop dialog for new record in Dynamics Ax 2012

Create date effective Table

clip_image002

When you set the ValidTimeStateFieldType property it will automatically create the ValidFrom/to fields

clip_image004

 

clip_image005

 

Crete a new form from template SimpleListDetails

Drag the table to the datasource

It will set the date effective query to the default:

clip_image007

Then set the grid datasource and add fields to the grid

clip_image009

Create the groups possibly based on the table groups (otherwise drag fields from the datasource one by one)

clip_image011

clip_image013

clip_image015

 

Add in the init

public void init()
{
    super();
    //Initialize splitter
    verticalSplitter = new SysFormSplitter_X(VSplitter, GridContainer, element, 300);
 
    //For Dates
    //DateEffectivenessPaneController::constructWithForm(this, EF_DateEffectiveTrial1_ds);
 

    //For DateTime
    DateEffectivenessPaneController::constructWithForm(this, EF_DateEffectiveTrial1_ds, true, true, true);
}
 

The form will look like this

clip_image016

 


 

Change the properties of the datasource like this:

clip_image018

 

This allows to change the effective dates manually


 

Create a new Drop Dialog:

Create a new form from template Drop Dialog

 

clip_image020

 

clip_image022

                                                                                                                clip_image023

 

Add those two methods

clip_image024

private ValidFromDateTime getEffectiveDate()
{
    return effectiveDate.dateTimeValue();
}
 
public void init()
{
    ValidFromDateTime           validFromDefaultDate;
    ValidToDateTime             validToDefaultDate;
    Timezone                    userTimeZone;
    EF_DateEffectiveTrial1      common;
 
    super();
 
    common = element.args().record();
    userTimeZone = DateTimeUtil::getUserPreferredTimeZone();
    validFromDefaultDate = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), userTimeZone); //common.ValidFrom;
    effectiveDate.dateTimeValue(validFromDefaultDate);
 
    //expirationDate.dateValue(validToDefaultDate);
    //set the \Forms\EF_DropDialogEffectiveDate\Designs\Design\[Group:DialogCommit]\[ButtonGroup:ButtonGroup]\CommandButton:OKButton
    //AutoDeclaration = Yes
 
    OKButton.helpText(strFmt("@SYS327712",tableId2pname(common.TableId)));
}
 


 

Create a new menuItem Display

 

clip_image026

 

Create a new DropDialog Button

clip_image027

clip_image028

clip_image029

clip_image030

 

Override the dialogClosed method

clip_image031

 

public void dialogClosed(FormRun _formRun)
{
    Object                          formRunObj;
    ValidFromDateTime               effectiveDate;
    EF_DateEffectiveTrial1          record, recordNew;
    
    super(_formRun);
    
    formRunObj = _formRun;
    
    if (_formRun.closedOk())
    {
        if (formHasMethod(formRunObj, 'getEffectiveDate'))
        {
            effectiveDate = formRunObj.getEffectiveDate();
        }
    
        record = EF_DateEffectiveTrial1_ds.cursor();
        buf2Buf(record, recordNew);
        recordNew.ValidFrom = effectiveDate;
        recordNew.insert();
 
        EF_DateEffectiveTrial1_ds.research(true);
    }
}
 

The form will look like this

clip_image033

 

Thursday, June 6, 2019

batch server setup in Dynamics Ax 2012


https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/137418/batch-job-not-executing

I did just the first 2 point and worked

1. verify if you have marked your current server as TRUE for "IsBatchServer" property.

clip_image002

2. verify the Batch groups, if you have selected the correct servers in there.

clip_image004

clip_image005

3. Perform incremental CIL.

 

4. If nothing of above works, Opt to restart AX services preceded by SQL services Restart.

 

Sunday, June 2, 2019

forms and tables methods call sequences in Dynamics Ax 2012

This gives the information of method calls in the form level while
1. Opening the Form.
2. Creating/Updating/Deleting the record in the Form.
3. Closing the Form.
Sequence of Methods calls while opening the Form
Form --- init ()
Form --- Datasource --- init ()
Form --- run ()
Form --- Datasource --- execute Query ()
Form --- Datasource --- active ()

Sequence of Methods calls while closing the Form
Form --- canClose ()
Form --- close ()

Sequence of Methods calls while creating the record in the Form
Form --- Datasource --- create ()
Form --- Datasource --- initValue ()
Table --- initValue ()
Form --- Datasource --- active ()

Sequence of Method calls while saving the record in the Form
Form --- Datasource --- ValidateWrite ()
Table --- ValidateWrite ()
Form --- Datasource --- write ()
Table --- insert ()

Sequence of Method calls while deleting the record in the Form
Form --- Datasource --- validatedelete ()
Table --- validatedelete ()
Table --- delete ()
Form --- Datasource --- active ()

Sequence of Methods calls while modifying the fields in the Form
Table --- validateField ()
Table --- modifiedField ()

Init()   
The first event fired. This is where you will populate default values or add runtime controls.
Think of this as the starting point for everything. It is what happens first.
You can also populate variables that you will use to alter programmability throughout your class.

ds init()   
Each form has a connection to data known as the data source.
Here you can make changes to the way that the form grabs data without actually changing the core data source information.
So maybe, for just this one form,
you want to filter customers by their groups – easily done by going into this method (aka event) and changing things.

Run   
Tells the form to get busy.
You can often dynamically change data sources here, so you could choose to load one data source
based on a set of circumstances

Ds execute Query()
This is where you will often make changes to just to just an individual data source.
For example, in this example we add a queryfilter which acts like a where clause on the Dynamics AX generated query.

canClose()   
Do users want to close the form. If so certain things need to pass such as validate those values as actually true

Close()   
After a form closes, do you want to do anything special?
Maybe you want to open up a new form after the form closes or something else.

I found here a very nice slide: https://www.slideshare.net/HamdaouiAmine/microsoft-dynamics-ax2012-forms-and-tables-methods-call-sequences-30159669

I copied it here because for those like me that can’t access slideshare from work due to the company’s firewall rules:

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image