Month: January 2015

WORKING WITH CUSTOMIZED AIF (SERVICE OPERATION : UPDATE)

EntityKey[] _entityKeyList = null;

List<CriteriaElement> _criteriaList = new List<CriteriaElement>();
CriteriaElement _criteria = new CriteriaElement();

_criteria.DataSourceName = “ContactTable”;
_criteria.FieldName = “RecID”;
_criteria.Operator = Operator.Equal;
_criteria.Value1 = “5637144586”;

_criteriaList.Add(_criteria);

QueryCriteria _queryCriteria = new QueryCriteria();
_queryCriteria.CriteriaElement = _criteriaList.ToArray();
try
{
_entityKeyList = this.getClientObject().findKeys(this.getCallContext(), _queryCriteria);
AxdContactQuery _contactQuery = this.getClientObject().read(this.getCallContext(), _entityKeyList);

AxdEntity_ContactTable _contactTable = _contactQuery.ContactTable[0];
_contactTable.ContactName = “Ahmed Muhammad Alam”;

this.getClientObject().update(this.getCallContext(), _entityKeyList, _contactQuery);
RTB_ErrorBox.Text = “Updated successfully”;
}
catch(Exception ex)
{
RTB_ErrorBox.Text = ex.Message;
}

Advertisements

Working with customized AIF (Service Operation : Find)

AxdContactQuery _trans = new AxdContactQuery();
CriteriaElement[] criteriaElement = new CriteriaElement[1];
criteriaElement[0] = new CriteriaElement();
criteriaElement[0].DataSourceName = “ContactTable”;
criteriaElement[0].FieldName = “ContactID”;
criteriaElement[0].Value1 = “CNT-0003”;

QueryCriteria queryCriteria = new QueryCriteria();
queryCriteria.CriteriaElement = criteriaElement;

try
{
_trans = this.getClientObject().find(this.getCallContext(), queryCriteria);
lstBox.Items.Add(_trans.ContactTable[0].RecId);
}
catch (Exception ex)
{
RTB_ErrorBox.Text = ex.Message;
}

Working with customized AIF (Service Operation : Delete)

KeyField keyField = new KeyField() { Field = “RecId”, Value = “5637144589” };

// Create an entity key instance and put in the key field data
EntityKey entityKey = new EntityKey();
entityKey.KeyData = new KeyField[1] { keyField };
EntityKey[] entityKeys = new EntityKey[1] { entityKey };

try
{
this.getClientObject().delete(this.getCallContext(), entityKeys);
RTB_ErrorBox.Text = “Deleted successfully.”;
}
catch (Exception ex)
{
RTB_ErrorBox.Text = ex.Message;
}

Working with customized AIF (Service Operation: Read)

ContactQueryServiceClient _client = new ContactQueryServiceClient();
AxdContactQuery _contactQuery = new AxdContactQuery();
EntityKey[] entityKeys = new EntityKey[1];

entityKeys[0] = new EntityKey();
entityKeys[0].KeyData = new KeyField[1];
entityKeys[0].KeyData[0] = new KeyField();
entityKeys[0].KeyData[0].Field = “RecId”;
entityKeys[0].KeyData[0].Value = “5637144586”;
try
{
_contactQuery = _client.read(this.getCallContext(), entityKeys);
lstBox.Items.Add(_contactQuery.ContactTable[0].ContactID + ” ” + _contactQuery.ContactTable[0].ContactName + ” ” + _contactQuery.ContactTable[0].ContactEmail);
}
catch (Exception ex)
{
RTB_ErrorBox.Text = ex.Message;
}

Working with customized AIF (Service Operation : Create)

//Service Declaration
ContactQueryServiceClient _client = new ContactQueryServiceClient();
AxdContactQuery mycontactQuery = new AxdContactQuery();
AxdEntity_ContactTable trans = new AxdEntity_ContactTable();

//trans.MyContactIDSpecified = true;
trans.ContactEmail = “containerblue@gmail.com”;
trans.ContactID = “CNT-0005”;
trans.ContactName = “Ahmed Alam”;
trans.ContactMobile = “0535865xxx”;

mycontactQuery.ContactTable = new AxdEntity_ContactTable[1] { trans };
try
{
_client.create(this.getCallContext(), mycontactQuery);
RTB_ErrorBox.Text = “Inserted successfully.”;
}
catch (Exception ex)
{
RTB_ErrorBox.Text = Convert.ToString(ex.Message);
}

Checklist for customized workflow AX 2012

1.      Workflow configuration

Should defined the batch group within AX 2012.
Should configured workflow infrastructure configuration.
Should defined workflow user id for the “System Service Account”

2.      Customization: Phase I

Workflow category should be created.
Required query has been created with dynamic property should be “True/Yes”
Base Enumerator must be created.
Addition upper define type of enumerator within the required table.
“CanSubmitToWorkflow” method must be defined.
Display type menu should be created to set the properties of the following caetgories.

–           EnumTypeParameter [e.g. ModuleAxapta]

–           EnumParameter [e.g. SalesOrder]

3.      CUSTOMIZATION: PHASE II

“Workflow Type” must be created with the help of “Workflow Type Wizard”.
System will generate one “Private” project with few classes, display menu items and workflow type.
On the designated “Form” workflow should be enabled and its associated properties should be defined properly.
Code snippet should be there for “Submit” within the “*SubmitManager” class.
Code snippet should be there as per requirement within the “*EventHandler” class.

–           Cancelled

–           Completed

–           Returned etc.

Rename both the wizard generated menus within this project.

4.      CUSTOMIZATION: PHASE III

Create a “Workflow Approval” through “Workflow Approval Wizard”.
System will generate one “Private” project with few classes, display menu items and workflow approval.
Drag the approval element to the “Workflow Type > Supported Element”.
Code snippet should be there as per requirement within the “*EventHandler” class.

–           Cancelled

–           Completed

–           Returned etc.

Rename the display menu item.

5.      CONFIGURATION: PHASE IV

Drag the “Display Menu” into the “Menu” from the AOT which was created in phase I.
Desired workflow should be configured/created.
Test the workflow within the required module.

Compile AX 2012 R2 or later through command prompt

We can compile the Microsoft Dynamics AX 2012 R2 or later even through command prompt and it will take comparatively less time than GUI mode.

Server file location:

– D:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin

On command prompt:

axbuild.exe xppcompileall /s=01 /altbin=”C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin” /log:”C:\Temp”