Alfasith AX

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

Thursday, December 27, 2018

Code to fetch the form Notes in AX 2012 / D365

Hi,

Print FormLetterRemarks::find( SalesOrder.LanguageId, FormTextType::SalesPackingSlip).Txt;

You can get all the form notes by selecting the enum FormTextType::

Regards,
Alfasith

New line / Line break in expression of SSRS

Hi,

=First(Fields!CompanyAddress.Value, "EcomPackingSlipTmp") & vbcrlf &
First(Fields!CompanyURL.Value, "EcomPackingSlipTmp") & vbcrlf &
First(Fields!CompanyPhone.Value, "EcomPackingSlipTmp")

Regards,

Make a group by in SSRS

Hi,

Sample, here I have Amount values that is sum(Amount) all the sales Order, but I need the group by Sales Id.

below expresion works for me when I add this filed group by in that particular tablix.

=Sum(CDbl(Fields!Amount.Value))

Regards,

Thursday, November 29, 2018

How to achieve alerts for child tables in D365

Hi,

Microsoft D365 doesn't support alert handling for child tables when there is a parent table in a form.

We can do a work around to handle this by using the sysTableBrowser URL for the particular table which is not listed in any form.


Regards,

Tuesday, November 27, 2018

How to run a job in D365

Hi,

This is not similar to AX 2012, we needs to invoke it like how we are opening the table browser.

1. Create a item as Runnable class,
2. Add your business Logic codes in main method().
3. Call the below URL with your instance URL and Class name.

https://<instanceURL>/?mi=SysClassRunner&cls=YYYNumberSeqLoad&cmp=YYY

https://URL/?mi=SysClassRunner&cls=EcomPurchOrderEDI&cmpECOP&cmp=ECOP

Regards

Monday, November 26, 2018

The menu item with name XXX could not be opened.

Hi,

Can you please check the form init, which can be adjustable with DB init will get it resolved.


Thanks,

Saturday, November 17, 2018

cannot access a disposed object, Object name 'memory model provider has been already disposed


Hi,

Cannot access a disposed object,
Object name 'memory model provider has been already disposed

Prompts an error when you built the model you have.

Solution:

1. Full built all the model files.
2. Restart the IIS.
3. Rerun the VS.

Regards,

Thursday, November 15, 2018

Job to list all the fields in particular table in D365

Hi,


class AlfasithTableFieldList
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {

        TableName           tableName = 'SalesTable';
        SysModelElement     sysModelElementTables;
        SysModelElement     SysModelElementFields;
        DictField           dictField;
        ;
        while select    sysModelElementTables
            where   sysModelElementTables.ElementType               == UtilElementType::Table       &&
                    sysModelElementTables.Name                      == tableName
            join SysModelElementFields
                where   SysModelElementFields.ElementType           == UtilElementType::TableField  &&
                        SysModelElementFields.ParentModelElement    == sysModelElementTables.RecId
        {
            dictField = new DictField(sysModelElementTables.AxId, sysModelElementFields.AxId);
            print dictField.name();
        }
    }

}

Regards,

Tuesday, October 30, 2018

The name [**TableName**] does not denote a class, a table, or an extended data type in D365.

Hi

The Table which you added to the solution / Project is not in the model package, So you needs to add that missing package in to your model.

Sample steps followed below :


In my case :  I did add the FiscalBook in to my model package.

Dynamics 365 > Model Management  > Update model parameter 

Select your model and click Next

Check / Select the FiscalBook in that listed package list and select Next.

Finish ends your dialog.

Regards,

Wednesday, October 24, 2018

Print HTML tags as run value in SSRS 2012 R3 / D365

Hi,

1. Select the text filed.
2. Click on the expression /  filed values (right click)
3. Select placeholder properties.
4. General tab  > Markup type > HTML as style.


Regards,

Tuesday, October 23, 2018

Deploy all the report in CMD for D365

Hi,

1. Run the powershell command prompt as administrator.
2. Paste the code for specific reports.
here my sample is PurchPurchaseOrder.Report

K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -Module ApplicationSuite -ReportName PurchPurchaeOrder.Report -PackageInstallLocation “K:\AosService\PackagesLocalDirectory”

3. To deploy all the reports.

K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “K:\AosService\PackagesLocalDirectory”


Regards,

Monday, October 15, 2018

W3WP process attaching issues / debugger not enabled in D365


When ever you find w3wp process attaching issues or multiple times of w3wp process




1. Please check do local service w3c loading service is running.



2.  Please do check Load symbol for items in the solution.
D365 > Option


3. Restart the IIS.


Hope your issue will get resolved.

Conformation:


Thanks,


Sunday, October 14, 2018

Error: "The model element was saved with unparsable source code and cannot be used".

Hi,

This is error because of multiple times changes in the blocks of code. This is the error on building a recent changes which is not affecting by last changes.

Solution.

1. Take a complete old code in to Notepad and save the class and built the object.
2. Now replace this blocks of code with the buffer you have in clipboard.
3. You may save and build now.

Thanks,


Wednesday, June 20, 2018

Relation between ProjPostTransView and PurchOrder

Hi

Add the ProjTransId in to that view from ProjItemTrans.

display PurchId PurchId()
{
    PurchLine       PurchLine;
    ProjItemTransView   projItemTransView;
    InventTransOrigin       inventTransOrigin;
    ProjItemTrans           projItemTrans;
    ;
    if(this.ProjTransId)
    {
        select projItemTrans where projItemTrans.ProjTransId == this.ProjTransId;
        select PurchLine where PurchLine.ProjTransId == projItemTrans.ProjTransIdRef
                                        && PurchLine.ItemId == projItemTrans.ItemId;
        //select InventTransId from projItemTransView where projItemTransView.ProjTransId == this.ProjTransId
        //join inventTransOrigin where inventTransOrigin.InventTransId == projItemTransView.InventTransId;
        return PurchLine.PurchId;
    }
    else return "";
}

Thanks,

Monday, March 5, 2018

Joining a table in datasource without adding the table in to the form data source in AX 2012

Hi,

In my case I needs to add the purchTable as range but I dont want to add the table in that form datasource.

I added the below code in the PurchLine init().

public void init()
{
    Query                   query = new Query();
    QueryBuildDataSource    purchTableDS,purchLineDS;
    QueryBuildRange         activityNum,purchStatus;
    ProjBudgetLine          projBudgetLine;
    Query                   queryDB;
    QueryBuildDataSource        qbdsPurchLine;
    QueryBuildDataSource        qbdsPurchTable;
    super();
    projBudgetLine  =   element.args().record();
    qbdsPurchLine = this.query().dataSourceTable(tableNum(PurchLine));
    qbdsPurchLine.addRange(fieldnum(PurchLine, ActivityNumber)).value(queryvalue(projBudgetLine.ActivityNumber));

    qbdsPurchTable = qbdsPurchLine.addDataSource(tableNum(PurchTable));
    qbdsPurchTable.addLink(fieldNum(PurchTable, PurchId), fieldNum(PurchLine, PurchId));
    qbdsPurchTable.addRange(fieldnum(PurchTable, DocumentStatus)).value(queryValue(DocumentStatus::PurchaseOrder));

}

Get purchase Lines Sales tax in AX 2012

    TaxJournalTrans      taxJournal;

    select SourceTaxAmountCur,TaxAmount from taxJournal where taxJournal.TransRecId  == vendPurchOrderJour.RecId
                        &&  taxJournal.TransTableId     == tableNum(vendPurchOrderJour)
                        &&  taxJournal.InventTransId    == purchLineAllVersions.InventTransId;
    if(vendFormletterParameters.TaxSpecPrintLevel == TaxSpecPrintLevel::Currency)
    {
        purchPurchaseOrderTmp.VAT = taxJournal.SourceTaxAmountCur;
    }
    else if(vendFormletterParameters.TaxSpecPrintLevel == TaxSpecPrintLevel::CurrencyMST)
    {
        purchPurchaseOrderTmp.VAT = taxJournal.TaxAmount;
    }
    else
        purchPurchaseOrderTmp.VAT = 0.0;

Regards,

Tuesday, February 20, 2018

Depley packages from DEV to SAT in D365

Hi,

1. Create a package by the model that you extended.
Save to particular location (30-50 mins).

2. Log in to LCS. Select shared asset library.



3  Select Software deployment packages.
4. Add  by select the + and upload the packages and publish.
You will notify 2 packages for what you created.
5. Select the SAT environment in LCS and get in to that environment.
Get same in to the Asset Library of the SAT.
6. Then select maintain and update.
This will be in 19 steps that takes 2 hrs mins.

Thanks,

Thursday, February 15, 2018

Code to clear the cache value / Last used values in SSRS through controller class in AX 2012

Hi,


public static void main(Args _args)
{
    SrsReportRunController controller  = DASPaymentVoucherController::construct();
    controller.parmArgs(_args);
    switch(_args.menuItemName())
    {
        case menuitemOutputStr(DASReceiptVoucherReport):
        controller.parmReportName(ssrsReportStr(DASPaymentVoucher, ReceiptReport));
        break;
        case menuitemOutputStr(DASPaymentVoucherReport):
        controller.parmReportName(ssrsReportStr(DASPaymentVoucher, Report));
        break;
        case menuitemOutputStr(DASPettyCashVoucherReport):
        controller.parmReportName(ssrsReportStr(DASPaymentVoucher, PettyCashReport));
        break;
    }

    controller.parmShowDialog(true);
    controller.parmLoadFromSysLastValue(false);
    controller.startOperation();
}

Thanks,

Wednesday, February 14, 2018

Get the values from ProjProposalTotal forms in AX 2012

Hi,

static void Job83(Args _args)
{
  ProjProposalTotals      ProjProposalTotals;
    container               taxCal;
    AmountCur               taxAmount;
        ProjProposalJour projProposalJour = ProjProposalJour::find('PROP-0019');

        ProjProposalTotals  = new  ProjProposalTotals(projProposalJour);
        ProjProposalTotals.calc();
taxCal = ProjProposalTotals::displayFieldsServer(projProposalJour.RecId);
        taxAmount = conPeek(taxCal, ProjProposalTotals::posSumTax());
   
        InvoiceAmount  = projProposalJour.InvoiceAmount - taxAmount;
        TaxAmount       = taxAmount;
        CurrencyCode   = projProposalJour.CurrencyId;
        Amountstr   = Global::numeralsToTxt_UAE(projProposalJour.InvoiceAmount);
}

Regards,

Get cost to complete, Cost at complete in Project WBS in AX 2012

static void AlfasithProjWBSCost(Args _args)
{
    hierarchyTreeTable          hierarchyTreeTablePre;
    smmActivities               smmActivitiesPre;
    psaActivitySetup            psaActivitySetupPre;
    ProjWBSUpdateController     controller;
    while    select hierarchyTreeTablePre  where hierarchyTreeTablePre.HierarchyId  == 'EWIG-00032'
    {
        smmActivitiesPre  = smmActivities::findWithRecId(hierarchyTreeTablePre.RefRecId);
        psaActivitySetupPre = PSAActivitySetup::findActivityNumber(smmActivitiesPre.ActivityNumber);
        controller = new ProjWBSUpdateController(hierarchyTreeTablePre.HierarchyId,
                psaActivitySetupPre.CalendarId,
                null,
                null,
                null,
                null,
                false,
                ProjViewType::CostTrackingView,
                null,
                null,
                true);
        controller.updateOutlineNumbersAndPublishInPreOrder();
        print controller.outlineNumberFor(hierarchyTreeTablePre.ElementNumber);
        //Cost estimnation View
        print controller.actualCostFor(hierarchyTreeTablePre.ElementNumber);
        print controller.costAtCompleteFor(hierarchyTreeTablePre.ElementNumber);
        print controller.plannedCostFor(hierarchyTreeTablePre.ElementNumber);

        /*Total actualCost = controller.actualCostFor(_hierarchyTreeTable.ElementNumber);
        Total costAtComplete = controller.costAtCompleteFor(_hierarchyTreeTable.ElementNumber);
        Total costToCompleteAmount = costAtComplete - actualCost;
        */
    }
    pause;

}

Relation between PSAProjProposalProj with PSAContractLineItems in AX 2012


static void Job80(Args _args)
{
     psaProjProposalProj psaProjProposalProj;
     projOnAccTrans projOnAccTrans;
     projProposalOnAcc projProposalOnAcc;
     psaContractLineItems psaContractLineItems;
     while select psaProjProposalProj where psaProjProposalProj.ProjProposalId == "UDI-000127"//_projProposalJour.ProposalId
            join projOnAccTrans where projOnAccTrans.ProjID == PSAProjProposalProj.ProjId
                                    && projOnAccTrans.TransactionOrigin == ProjOrigin::Prepayment
            join projProposalOnAcc where projProposalOnAcc.TransId == projOnAccTrans.TransId
                                    && projProposalOnAcc.ProposalId == PSAProjProposalProj.ProjProposalId
            join psaContractLineItems
                        where psaContractLineItems.FeeProjId == psaProjProposalProj.ProjId
        {
            info(strFmt("%1",psaContractLineItems.LineValue));
        }
}

Disable/hide report parameter on form AX 2012

Hi,

There is an attribute makes this visibility control in Contrac class level.

This can be also achieve through visual studio parameters property of visibility.

[
DataMemberAttribute,
SysOperationControlVisibilityAttribute(false)
]
public AccountNum parmCustomerAccount(AccountNum  _accountNum = accountNum )
{
    accountNum = _accountNum;
    return accountNum;
}

Thanks,
Alfasith

Tuesday, February 13, 2018

Arabic letters in the report needs to be right alignment particulary in Cheque in SSRS

Hi,

Pass another filed in insert method along with your context as language by getting a values in LedgerJournalTrans values like 'en-us', 'en-ar'..

In the Alighment property of the textbox select the Horizontal  fx   with below commands.

iif(Fields!Languague.Value="en-ar","right","Left")


Query not value enum in AX 2012

Hi,

    qbrLogStatus    = qbdsDASProjLogLines.addRange(fieldnum(DASProjLogLines,ProjLogStatus));
    qbrLogStatus.value(SysQuery::valueNot(enum2str(DASProjLogStatus::Superseded)));

Thanks,

Saturday, January 13, 2018

Dialog date field and OK CANCEL in job AX 2012

public static void dialogDate()
{
    Dialog      dialog;
    DialogField field;
    ;
    dialog = new Dialog("Submitted Date");
    dialog.addText("Select submitted date:");
    field = dialog.addField(identifierStr(TransDate));

    dialog.run();
    if (dialog.closedOk())
    {
        info(field.value());
    }
}

Thursday, January 11, 2018

Management Reporter has not yet been configured on the server. Contact your server administrator to publish the connection from within the Management Reporter Configuration Console.

Hi,

Whenever you get the error
'Management Reporter has not yet been configured on the server. Contact your server administrator to publish the connection from within the Management Reporter Configuration Console.'
 you please republish the console or can be easily solved by.
1. make the LedgerParameters table filed MangementReporterURL file visible :Yes.
2. Just place your MR URL to make it success.
mrd://?ServerConnection=http://<ServerName>:4712/&Company=<DefaultCompanyName>
mrd://?ServerConnection=http://MicrosoftIndDEV:4712/&Company=IMSD.

Regards,

FileNameSplit() to slip the Directory, file name and extension in D365 FnO

 Hi,     /// <summary>     /// Validate the Fileformat     /// </summary>     /// <param name = "filepath">FileP...