This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
02 March 2023
25 February 2023
13 February 2023
Form control value versioning view Manager and make bold the modified value in Form Control in D365 FO
x++ code to set bold of field value based on the modification in D365FO Form control
Form : PurchVendorPortalResponses
private void registerForChangeTracking()
{
viewManager = VersioningDocumentViewManager::construct();
viewManager.registerDataContainerForDataSource(PurchaseOrderResponseHeader_DS,
VersioningDocumentViewDataContainer::constructFromDataSource(
PurchaseOrderResponseHeader_DS,
[fieldStr(PurchaseOrderResponseHeaderAllVersions, PurchTableVersion)],
fieldStr(PurchaseOrderResponseHeaderAllVersions, VersionDateTime),
new PurchaseOrderResponseHeaderMapper()));
viewManager.registerDataContainerForDataSource(PurchaseOrderResponseLine_DS,
VersioningDocumentViewDataContainer::constructFromDataSource(
PurchaseOrderResponseLine_DS,
[fieldStr(PurchaseOrderResponseLineAllVersions, PurchTableVersion),
fieldStr(PurchaseOrderResponseLineAllVersions, PurchaseOrderResponseLine)],
fieldStr(PurchaseOrderResponseLineAllVersions, VersionDateTime),
new PurchaseOrderResponseLineMapper()));
viewManager.registerControlForTracking(PurchaseOrderResponseHeader_DlvTerm);
viewManager.registerControlForTracking(PurchaseOrderResponseHeader_DlvMode);
viewManager.registerControlForTracking(PurchaseOrderResponseHeader_VendorRef);
viewManager.registerControlForTracking(PurchaseOrderResponseLine_PurchQty);
viewManager.registerControlForTracking(PurchaseOrderResponseLine_ConfirmedDlv);
viewManager.registerControlForTracking(PurchaseOrderResponseLine_ExternalItemId);
viewManager.registerControlForTracking(PurchaseOrderResponseLine_Name);
}
=====
Extension to add extra feild.
/// <summary>
///
/// </summary>
[ExtensionOf(formstr(PurchVendorPortalResponses))]
final class TestPurchVendorPortalResponses_Extension
{
/// <summary>
///
/// </summary>
public void init()
{
next init();
viewManager.registerControlForTracking(PurchaseOrderResponseLine_PurchPrice);
}
}
====
Similarly:
Form: PurchVendorPortalAllResponse
Method: registerForChangeTracking()
Extenion to add new control for tracking and bold:
[ExtensionOf(formstr(PurchVendorPortalAllResponse))]
final class TestPurchVendorPortalAllResponse_Extension
{
public void init()
{
next init();
VersioningDocumentViewManager viewManager = this.getViewManager();
viewManager.registerControlForTracking(PurchaseOrderResponseLineAllVersions_PurchPrice);
}
}
23 October 2022
Modify Email Subject for a report in D365 F&O from x++
Modify Email Subject for a report in D365 F&O from x++
10 September 2022
Get object of Caller Form In Extension Class/ element to use in init extenion in D365Fo / Is it possible to get element.args() from an extended method in D365FO
Get the selected records in the form grid in class
class ClassParmData
{
CustTable
custTable;// table buffer declaration
}
public static void main(Args args)
{
ClassParmData
parmData;
Table1
table1;
FormDataSource
fds;
if(args.record().TableId
== tablenum(CustTable))
{
custTable
= args.record(); // assigning the selected record
}
fds
= custTable.dataSource();// getting the datasource
parmData=
new ClassParmData(fds); //passing the form datasource to New() method
}
void new(FormDataSource fdst) //
receving the datasource to fdst-FormDataSource
{
//
1st optoin to do this
MultiSelectionHelper
helper = MultiSelectionHelper::construct();
helper.parmDatasource(fdst);
custTable
= helper.getFirst();
while
(custTable.RecId != 0)
{
custTable
= helper.getNext();
}
//
second way
for(custTable
= fdst.getFirst(true); custTable; custTable = fdst.getNext()) //
fdst.getFirst(True) to select marked records
{
info(strfmt(custTable.Field1));
}
//if
you are updating some records in the form write the below line to refresh the
data in form.
//fdst.research();
}
void
parmFormDataSource(formDataSource fdst)
{
for(custTable
= fdst.getFirst(true); custTable; custTable = fdst.getNext()) //
fdst.getFirst(True) to select marked records
{
info(strfmt(custTable.Field1));
}
//if
you are updating some records in the form write the below line to refresh the
data in form.
//fdst.research();
}
01 August 2022
Sys operation frame work with example and Multi select lookup using Sys operation frame work service class
This post is to get the sysoperation framework exmaple with the multi select lookup using UI builder class.
Step1. Create a contract class as follows.
[DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(TRGPlannedPOGroupUIBuilder))]
internal final class TRGPlannedPOGroupContract implements SysOperationValidatable
{
List saesOrderNumber;
[DataMemberAttribute("Sales order"),AifCollectionTypeAttribute("Sales order", Types::String),
SysOperationLabelAttribute(literalStr("Sales order"))]
public List parmSalesOrder(List _saesOrderNumber = saesOrderNumber)
{
saesOrderNumber = _saesOrderNumber;
return saesOrderNumber;
}
public boolean validate()
{
boolean isValid = true;
List salesOrderList = new List(Types::String);
salesOrderList = this.parmSalesOrder();
if(!salesOrderList.elements())
{
isValid = checkFailed("Sales order should not be empty");
}
return isValid;
}
}
Step2: Create the service class.
internal final class TRGPlannedPOGroupService
{
List salesOrderList;
public void processGroup(TRGPlannedPOGroupContract _contract)
{
ListIterator listIterator;
listIterator = new ListIterator(_contract.parmSalesOrder());
while (listIterator.more())
{
Info(listIterator.value());
listIterator.next();
}
}
}
Step 3: Create controller class:
class TRGPlannedPOGroupController extends SysOperationServiceController
{
public static void main(Args _args)
{
TRGPlannedPOGroupController controller =
new TRGPlannedPOGroupController(classStr(TRGPlannedPOGroupService),
methodStr(TRGPlannedPOGroupService, processGroup),SysOperationExecutionMode::Synchronous);
TRGPlannedPOGroupContract contract = controller.getDataContractObject();
//contract.parmArgs(_args);
controller.startOperation();
}
public ClassDescription caption()
{
return "Group planned purchase orders";
}
public LabelType parmDialogCaption(LabelType _dialogCaption = dialogCaption)
{
return "Group planned purchase orders";
}
}
Step 4: Create UI builder class to get multi slection lookup in the dailog.
internal final class TRGPlannedPOGroupUIBuilder extends SysOperationAutomaticUIBuilder
{
DialogField dialogSalesOrder;
TRGPlannedPOGroupContract plannedPOGroupContract;
DialogField availableCompanies;
private void SalesIdLookup(FormStringControl _control)
{
Query query;
container conSalesOrder;
query = new Query(queryStr(SalesTableListPage));
SysLookupMultiSelectGrid::lookup(query,_control,_control,_control,conSalesOrder);
}
public void build()
{
int i;
TRGPlannedPOGroupContract Contract;
contract = this.dataContractObject() as TRGPlannedPOGroupContract;
dialogSalesOrder = this.addDialogField(methodStr(TRGPlannedPOGroupContract, parmSalesOrder),contract);
}
public void postBuild()
{
TRGPlannedPOGroupContract Contract;
super();
contract = this.dataContractObject() as TRGPlannedPOGroupContract;
dialogSalesOrder = this.bindInfo().getDialogField(contract, methodStr(TRGPlannedPOGroupContract, parmSalesOrder));
dialogSalesOrder.lookupButton(FormLookupButton::Always);
}
public void postRun()
{
Query query = new Query();
QueryBuildDataSource qbdsLegalEntity = query.addDataSource(tablenum(SalesTable));
qbdsLegalEntity.fields().addField(fieldNum(SalesTable, SalesId));
container selectedFields = [tableNum(SalesTable), fieldNum(SalesTable, SalesId)];
SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), dialogSalesOrder.control(), query, false, selectedFields);
}
}
Service class to get the selected record and deleted matching records and refresh the form data source in D365 F&O
[DataContractAttribute] class ABCUserProfilesBulkDeleteContract { UserId userId; [DataMemberAttribute('UserId')] pu...
-
Please click here to access Custom Workflow step by step process:
-
public InventQty onHandInventory(ItemId itemId, InventSiteId inventSiteId,InventLocationId inventLocation) { InventOnhand inventOnh...
-
1. In classDeclaration extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase 2. Temp table properties should b...