D365FO

D365 Finance and Operations is the latest version of Microsoft Dynamics ERP. D365 Finance and Operations is a cloud based enterprise resource planning (ERP) service for enterprises and built on Microsoft Azure.

D365 Finance and Operations facilitates and support customer's unique requirement and also provide the flexibility to modify ERP system to align their requirement to support operation in more effective and efficient way without any changes in operation processes.

Moreover, D365FO provide better platform through ERP functionality to run constantly changing business in competitive and challenging environment without hassle of maintaining infrastructure and software.




How to add document note in D365

class VendAccountDocument_JKS
{

static void main(Args _args)
{
VendTable vendTable;
DocuType docuType;
DocuRef docuRef;
vendTable = VendTable::find('BRMF-000001');
docuType = DocuType::find('Note');
if (!docuType ||docuType.TypeGroup != DocuTypeGroup::Note)
{
throw error("Invalid document type");
}
docuRef.RefCompanyId = vendTable.dataAreaId;
docuRef.RefTableId = vendTable.TableId;
docuRef.RefRecId = vendTable.RecId;
docuRef.TypeId = docuType.TypeId;
docuRef.Name = 'Automatic note';
docuRef.Notes = 'Added from X++';
docuRef.insert();
info("Document note has been added successfully");
}

}


How to find SQL query in D365:


How to find SQL query out of the AOT query:


static void AOTQuery(Args _args)
{

QueryRun queryRun;

;

queryRun = new QueryRun(queryStr(QueryName));//add any name of query here in place of QueryName

info(queryRun.query().toString());

}



Saving last value on the form in D365: 



We can save last value on the form in AX so that when next time form will open it will show last saved value in the certain control:

We will take example to save value of below mark control on inventory counting form:



Below are the steps to enable this functionality:
1. Add below code snippet in class declaration:

AllOpenPosted allOpenPostedTrans
#define.CurrentVersion(1)
#localmacro.CurrentList
allOpenPostedTrans
#endmacro

2. Add below methods on the InventJournalTable form:

//To save default value in case if no last value available
public void initParmDefault()
{
allOpenPostedTrans= AllOpenPosted::All;
}

//To convert object to container
public container pack()
{
return [#CurrentVersion, #CurrentList];
}

//To convert container to object
public boolean unpack(container _packedClass)
{
int version = RunBase::getVersion(_packedClass);
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = _packedClass;
return true;
default:
return false;
}
return false;
}

//To save last design name
public IdentifierName lastValueDesignName
{
return element.args().menuItemName();
}

//To save last value
public IdentifierName lastValueElementName
{
return this.name();
}

//To save valueType in this case Form
public UtilElementType lastValueType()
{
return UtilElementType::Form;
}

//To store User Id
public UserId lastValueUserId()
{
return curUserId();
}

//To save Legal entity details
public DataAreaId lastValueDataAreaId()
{
return curext();
}
3. Add below code in Run(above Super) and Close(last in method) form's method:
Run:
xSysLastValue::getLast(this);
AllOpenPosted.selection(allOpenPostedTrans );

Close:
allOpenPostedTrans = AllOpenPosted.selection();
xSysLastValue::saveLast(this);

Compile and open form change value in the "show " control and close form next time form will open with last value in the show field.

I hope this will help !!!!


Create dialog run time and update respective record on  Dialog in D365:


Below are the method to create Dialog dynamically, inter value, fetch value from dialog and update dialog field automatically :

class DialogDemo extends RunBase
{
DialogField fieldAccount;
DialogField fieldName;
DialogField fieldGroup;
VendAccount vendAccount;
VendName vendName;
VendGroupId vendGroupId;

}

//Convert object to container
Public Container pack()
{
return conNull();
}

//Convert container to object
Public boolean unpack(container _packedClass)
{
return true;
}

// Dialog layout
Object dialog()
{
Dialog dialog;
dialog = super();
dialog.caption("Customer information");
dialog.allowUpdateOnSelectCtrl(true);
fieldAccount=dialog.addField(Extendedtypestr(VendAccount),"Vendor Account");
fieldName=dialog.addField(Extendedtypestr(VendName));
fieldName.enabled(false);
dialog.addTabPage("Details");
fieldgroup=dialog.addField(Extendedtypestr(vendGroupId));
fieldgroup.enabled(false);
return dialog;

}

//Fetch value from Dialog
public boolean getFromDialog()
{
vendAccount=fieldAccount.value();
vendName=fieldName.value();
vendGroupId=fieldGroup.value();
return super();
}

public static void main(Args _args)
{
DialogDemo dialogDemo= new DialogDemo();
if(DialogDemo.prompt())
{
DialogDemo.run();
}
}
//field value assignment
public void dialogSelectCtrl()
{
VendTable vendTable;
vendTable=vendTable::find(fieldAccount.value());
fieldName.value(vendTable.name());
fieldGroup.value(vendTable.VendGroup);

}

//To execute logic
Public void run()
{
info(strFmt("Vend Account: %1", vendAccount));
info(strFmt("Vend Name: %1", vendName));
info(strFmt("Vend Group: %1", vendGroupId));
}

No comments:

Post a Comment