Friday, September 4, 2020

Database synchronization failed. You may have to do a full build of the package ApplicationSuite and all of its dependent packages. D365 Error

 D365 synchronization Failed  Database synchronization failed. You may have to do a full build of the package ApplicationSuite and all of its dependent packages.


1) While doing a full build if you get the sync failure then check the error messages .If you have got any error as below.
"The CREATE UNIQUE INDEX statement terminated because a duplicate key"
then this is a purely data related issue you will have to fix the data and then sync again.

2) If you get errors during Data Entity synchronization then it might be a case that you have duplicated or used the same label for an entity which is being used.
Solution : Change the label of the Entity or table.

3) In case of below error .
SqlException:Execution Timeout Expired. 
Solution : Try to do it again after restarting .

Or else you will have to check the resources being utilized and use it to best . 

HOW TO GET THE BARCODE FROM CODE IN D365

 With the below code you can pass the text and get the corresponsing barcode value in Dynamics 365.

 public str getBarcode(str _barCodeText)
    {
        BarcodeCode128 barcode;

        barcode = Barcode::construct(BarcodeType::Code128);
        barcode.string(true, _barCodeText);
        barcode.encode();

        return barcode.barcodeStr();
    }

Thursday, September 3, 2020

What is LCS MICROSOFT DYNAMICS D365 Lifecycle Services

 LCS stands for Life cycle services.


It is a cloud based central repository for Microsoft Dynamics 365 Finance and Operations and to prepare and deploy projects which is called "Life Cycle Service".

You will need a microsoft account in order to login to the LCS portal.
https://lcs.dynamics.com

Once you have an associated onmicrosoft.com account you can login and create projects which are then linked to the VSTS services.

This helps the manager to have a high level overview of all the projects and the environments within a single window and manage it.
What is LCS, D365 Lifecycle Services, MICROSOFT DYNAMICS D365 Lifecycle Services, "Life Cycle Service".LCS portal.,
MICROSOFT DYNAMICS D365 Lifecycle Services


User/admin can do all the admin related activities from the LCS portal itself.

You can create as well as deploy new environments via LCS portal.
What is LCS, D365 Lifecycle Services, MICROSOFT DYNAMICS D365 Lifecycle Services, "Life Cycle Service".LCS portal.,
For more information visit the below link.
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/lifecycle-services/lcs.


Monday, August 17, 2020

Update multiple selected records on form in AX 2012 through Class and Passing parameter from Form to Class

 

Table:pocVehicle

Class:POCVehicleMasterClass

ManuItem:POCVehicleMasterClass


Method on Form button click:

void clicked()

{


MenuFunction mf;

  //POCVehicle pocVehicle;


Args args=new Args();

;

args.record(pocVehicle);

mf= new MenuFunction(identifierStr(POCVehicleMasterClass), MenuItemType::Action);

mf.run(args);


} 


Main Methods on Class POCVehicleMasterClass :


Public static void main(Args _args)


{

POCVehicle pocVehicle;


POCVehicleMasterClass myClass;


FormDataSource formdatasource;


Common common;

;


myClass= new POCVehicleMasterClass();


if(_args.record().TableId==tableNum(POCVehicle))


{

//Buffer selected records

common=_args.record();

//formdatasource=_args.record().dataSource();

//Records data source

formdatasource=common.dataSource();

//Passing parameter to class updateRecord method

myClass.UpdateRecord(formdatasource,_args);

}


}


Second method on the class:


Public void UpdateRecord(FormDataSource datasource, Args args)

{


POCVehicle pocvehicle;

FormDataSource formDataSource;

int recordCount, recorUpdated;

;


formDataSource= datasource;

//Count selected records

RecordCount= formDataSource.recordsMarked().lastIndex();

recorUpdated=0;


//Update all selected records

for(pocvehicle=formDataSource.getFirst(true)? formDataSource.getFirst(true): formDataSource.cursor() ; pocvehicle ;pocvehicle=formDataSource.getNext())


{

ttsBegin;

pocvehicle.Insurence= NoYes::No;

pocvehicle.update();

ttsCommit;

recorUpdated++;


}

//Refresh caller form datasource with same pointer


formDataSource.research(true);


info(strFmt('%1 records selected and %2 records updated ', RecordCount,recorUpdated));

  

}

Tuesday, May 28, 2019

code to fetch records between time

public real getSalesCount12to1(TransDate _dateInvoice,inventlocationid _location)
{
    CustInvoiceTrans             custinvoiceTrans;
    InventDim                    inventDim;
    InventLocation               inventLocation;
     utcDateTime         rangeStart, rangeEnd;
     TimeOfDay           startTime, endTime;
    int                     i;

 select custinvoiceTrans where custinvoiceTrans.InvoiceDate == _dateInvoice;
    startTime   = str2time("12:00:00 pm");
    endTime     = str2time("1:00:00 pm");
    rangeStart = DateTimeUtil::removeTimeZoneOffset(DateTimeUtil::newDateTime(custInvoiceTrans.InvoiceDate,startTime), DateTimeUtil::getUserPreferredTimeZone());
    rangeEnd   = DateTimeUtil::removeTimeZoneOffset(DateTimeUtil::newDateTime(custInvoiceTrans.InvoiceDate,endTime),DateTimeUtil::getUserPreferredTimeZone());

    while select count(RecId) from custInvoiceTrans group  by InvoiceId
            join inventDim
            where inventDim.inventDimId == custInvoiceTrans.InventDimId
            && inventDim.InventLocationId == _location
             && (custInvoiceTrans.InvoiceDate == _dateInvoice)
            && (custInvoiceTrans.createdDateTime >= rangeStart && custInvoiceTrans.createdDateTime < rangeEnd)
        {
            i++;
        }
        AWD_SaleshourlyTmp.NoOfInvoices12pm = i;//str2int(custInvoiceTrans.InvoiceId);


    return AWD_SaleshourlyTmp.NoOfInvoices12pm;

}

UI Builder Sample code

class SalesItemCategoryUIBuilder extends SrsReportDataContractUIBuilder
{
    DialogField  dialogFromDate,dialogToDate,dialogWarehouseName;
}
//
public void build()
{
    SalesItemCategoryContract rdpcontract = this.dataContractObject();

    dialogFromDate          = this.addDialogField(methodstr(SalesItemCategoryContract, parmFromDate), rdpContract);
    dialogToDate          = this.addDialogField(methodstr(SalesItemCategoryContract, ParmtoDate), rdpContract);
    dialogWarehouseName = this.addDialogField(methodstr(SalesItemCategoryContract, parmLocation), rdpContract);

}
//
public void getFromDialog()
{
    SalesItemCategoryContract contract = this.dataContractObject();
    super();
}
//
 public void initializeFields()
{
    SalesItemCategoryContract rdpcontract = this.dataContractObject();
}
//
public void postRun()
{
    Dialog      dialogLocal = this.dialog();
    DialogField dialogField;
    NoYes   confirm;

    super();
    dialogLocal.dialogForm().formRun().controlMethodOverload(false);
    dialogField  = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(SalesItemCategoryContract, parmLocation));

    dialogField.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(SalesItemCategoryUIBuilder,  warehouseLookup), this);
    dialogField.lookupButton(FormLookupButton::Always);
}//
private void warehouseLookup(FormStringControl warehouseLookUp)
{
    Query                   query= new Query();
    QueryBuildDataSource    qbds_SalesLocation;
    SysTableLookup          sysTableLookup;
    QueryBuildRange         qbr;
    container cnt;
    ForecastModel           forecastModel;
    ForecastSales           forecastsales;

   if (warehouseLookUp != null)
   {
        // Create an instance of SysTableLookup with
        // the current calling form control.
        sysTableLookup = SysTableLookup::newParameters(tablenum(AWDSalesLocation), warehouseLookUp);
        // Add fields to be shown in the lookup form.

        sysTableLookup.addLookupfield(fieldnum(AWDSalesLocation, warehousename), false);
        sysTableLookup.addLookupfield(fieldnum(AWDSalesLocation, Description), false);

        qbds_SalesLocation = query.addDataSource(tableNum(AWDSalesLocation));

        qbr = qbds_SalesLocation.addRange(fieldNum(AWDSalesLocation, warehousename));
        //qbr.value(dialogprojid.value());

        sysTableLookup.parmUseLookupValue(false);
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
   }
}

Sample RDP Code

[
    SRSReportQueryAttribute(queryStr(SalesItemcategoryQ)),

    SRSReportParameterAttribute(classStr(SalesItemCategoryContract))
]
class SalesItemCategoryDP extends SRSReportDataProviderBase
{
    SalesItemCategoryContract contract;
    SalesCategoryTmp         aWD_SalesItemCategoryTmp;


}


//Process Report


public void processReport()
{

     Query                   query;
     QueryRun                queryRun;
     SalesTable              salesTable;
     SalesLine               salesLine;
     EcoResCategory          ecoResCategory;
     Name                    salesLocation;
     TransDate               fromDate, toDate;

     contract              = this.parmDataContract() as AWDSalesItemCategoryContract;
     fromDate              = contract.parmFromDate();
     toDate                = contract.parmToDate();
     salesLocation         = contract.parmLocation();

    query =  this.parmQuery();

    query.dataSourceNo(1).addRange(fieldNum(SalesTable, CreatedDateTime)).value(queryRange(fromDate,toDate));
    query.dataSourceNo(1).addRange(fieldNum(SalesTable,AWDSalesLocation)).value(salesLocation);

    queryRun = new QueryRun(query);

    while(queryRun.next())
    {
        salesTable = queryRun.get(tableNum(salesTable));
        salesLine = queryRun.get(tableNum(salesLine));
        ecoResCategory = queryRun.get(tableNum(ecoResCategory));


        aWD_SalesItemCategoryTmp.ItemCategory = ecoResCategory.Code;
        aWD_SalesItemCategoryTmp.Location     = salesTable.AWDSalesLocation;
        aWD_SalesItemCategoryTmp.Sales        = salesLine.LineAmount;

        aWD_SalesItemCategoryTmp.insert();

    }



}



//getMethod

[
SRSReportDataSetAttribute('AWD_SalesCategoryTmp')
]
public AWD_SalesCategoryTmp getAWD_SalesItemCategory()
{
    select * from aWD_SalesItemCategoryTmp;

    return aWD_SalesItemCategoryTmp;
}