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;
        }