Thursday, June 19, 2014

Common Enterprise portal Grid methods

private DataSetViewRow CurrentExpenseHeaderRow
    {
        get
        {
            DataSetView dsv = this.DS_TrvExpTable.GetDataSet().DataSetViews["TrvExpTable"];
            return (dsv == null) ? null : dsv.GetCurrent();
        }
    }

    private IAxaptaRecordAdapter CurrentRecord
    {
        get
        {
            return (this.CurrentRow == null) ? null : this.CurrentRow.GetRecord();
        }
    }

    private IAxaptaRecordAdapter CurrentExpenseHeaderRecord
    {
        get
        {
            return (this.CurrentExpenseHeaderRow == null) ? null : this.CurrentExpenseHeaderRow.GetRecord();
        }
    }

Enterprise portal common methods

Call dynamics AX dataset method in Enterprise portal

boolean isValid = ((bool)this.DS_TSTimesheetEntry.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("validateTSTimesheetLineWrite"))

How to use infolog in Enterprise portal


Proxy.Info obj = new Proxy.Info(this.AxSession.AxaptaAdapter);
obj.add(Proxy.Exception.Info, "Testing");

How to call method other Webcontrol method in Enterprise portal


TrvUtility.GetAdminCustomFieldsDictionary(this.AxSession, this.Page.Session, TrvUtility.AdminCustomFields.Transaction);

How to refer / add exisitng webcontrol in your web control

Needs to write the below code in design form
<%@ Register Src="TrvUtility.ascx" TagName="AxUtility" TagPrefix="AxUtil" %>


How to access enum values in Enterprise portal

ApplicationProxy.TrvAppStatus approvalStatus;

approvalStatus = ((ApplicationProxy.TrvAppStatus)this.CurrentExpenseHeaderRow["ApprovalStatus"]);

approvalStatus = ApplicationProxy.TrvAppStatus.None;

return (ApplicationProxy.TrvAppStatus)approvalStatus;

compare Enum values

if ((ApplicationProxy.TrvExpType)this.CurrentRow["ExpType"] == ApplicationProxy.TrvExpType.Hotel)
                {
                    long recId = this.CurrentRow == null ? 0 : System.Convert.ToInt64(this.CurrentRow["RecId"], CultureInfo.InvariantCulture);
                    guestsLabel = ApplicationProxy.EPTrv.getGuestLabel(recId);
                }





Show / hide fields in AXgroup / grid in Enterprise portal

How to enable\ disable fields in Grid

foreach (DataControlField dcf in this.AxGroup_ExpenseHeaderOverviewLeft.DataControlFieldCollection)
            {
                axbf = dcf as AxBoundField;
                if (axbf != null)
                {
                    switch (axbf.DataField)
                    {
                        case "ExpNumber":
                        case "employeeName**":
                        case "Txt1":
                            axbf.Visible = true;
                            break;
                    }
                }
            }

How to enable\ disable fields in Group
            foreach (DataControlField dcf in this.AxGroup_ExpenseHeaderOverviewRight.DataControlFieldCollection)
            {
                axbf = dcf as AxBoundField;
                if (axbf != null)
                {
                    switch (axbf.DataField)
                    {
                        case "TrvRequisition!RequisitionNumber":
                        case "totalAmountAuthorized**":
                        case "totalApprovalAmountWithCurrencyCode**":
                            axbf.Visible = true;
                            break;

                        // Description is shown on right group during create, and on left group for Approver, for UX reasons
                        case "Txt1":
                            axbf.Visible = false;
                            break;
                    }
                }
            } 

If any field is visible in the group, do not hide the group in EP


 bool custVendGroupHideForApprover = true;
if (this.AxGroup_ExpenseHeaderCustomerVendorForApprover.Visible)
        {
            foreach (DataControlField dcf in this.AxGroup_ExpenseHeaderCustomerVendorForApprover.DataControlFieldCollection)
            {
                if (dcf is AxBoundField)
                {
                    // If any field is visible, do not hide the group
                    if (((AxBoundField)dcf).Metadata.Visible)
                    {
                        custVendGroupHideForApprover = false;
                        break;
                    }
                }
            }

            this.AxGroup_ExpenseHeaderCustomerVendorForApprover.Visible = !custVendGroupHideForApprover;
        }

Monday, May 12, 2014

Label files not appearing in AOT and Label editor


Label files are stored in model store and are copied to the server when the AOS is restarted.

In the situation where you are stuck and not able to reimport the label file, you can try the following:

•Delete the ald,alc and ali file for the specific label Id, from the folder "C:\Program Files\Microsoft Dynamics AX\60\Server\"Your Application name"\bin\Application\Appl\Standard". Make sure you delete files specific to your label ID.

•Restart AOS


Try to import the label file again. This is just a workaround. Normally label files are moved as a part of model only.

Wednesday, April 2, 2014

Dynamics AX Sorting Container

static void SR_sortContainer(Args _args)
{
container con = [5,1,2,'Sumit Loya',9, 'Ashish singh', NoYes::No];
str temp1;
str temp2;
int i;
int j;
container sorCon;
;
sorCon = con;
// Sort the container
for (i = 1; i <= conlen(sorCon); i++)
{
for (j = i + 1; j <= conlen(sorCon); j++)
{
temp1 = conpeek(sorCon, j);
temp2 = conpeek(sorCon, i);
if (temp1 < temp2)
{
sorCon = condel(sorCon, j, 1);
sorCon = conins(sorCon, j, temp2);
sorCon = condel(sorCon, i, 1);
sorCon = conins(sorCon, i, temp1);
}
}
}
conview(sorCon);
}

Only foreign key constraints are allowed on this table - How to rectify this best practice error.

This Best practice error comes when we create a normal relation. so for that create an index for the field on which you want to create a relation, and set theAlternateKey property of the index to "Yes". Now go to this table properties and set the PrimaryIndex property to the newly created index.Now when you create a foreign key based relation on the child table it will automatically create a relationship on the field that you have set as the PrimaryIndex. so in this way you can create a normal relation through foreign key relation and you can get rid of this Best practice error.
eg.
Table1 -> Field1,Field12
Index1 -> Field1 having AlternateKey set to "Yes".
Table1 -> properties->PrimaryIndex set to "Index1".
Table2 -> create a foreign key relation (Foreign key -> Primary key based)
then automatically a reation Table2.Table1 ==Table1.Field1 is created.
In this way you can easily create a relation on any field other than RecId. and also the BP error Only foreign key constraints are allowed on this table will remove.