10 December 2018

How to get or create dimension Id in Inventory Dimension in AX 2012 / D365 / AX7

How to create inventDimId using Invent Dimension values

InventDim inventDim,inventDimLoc;
InventJournalTrans inventJournalTrans;

inventDim.InventLocationId = this.Warehouse;
inventDim.InventSiteId = InventLocation::find(this.Warehouse).InventSiteId;
inventJournalTrans.inventDimId = InventDim::findOrCreate(inventDim).inventDimId;

29 September 2018

Adding display method in AX7 or D365

///
/// This class contains display methods for TVItemPriceUpdateForm form controls
///

public static class TVItemPriceupdate_Extension
{
[SysClientCacheDataMethodAttribute(true)]
public static display DataAreaId companyId(TVItemPriceUpdate _this)
{
CompanyInfo company;
select DataArea,TVMemberId from company
where company.TVMemberId == _this.TVMemberId;

return company.DataArea;
}

}

28 September 2018

Data entities in D365 AX7 to delete staging records

Data entities in D365 AX7 to delete staging records

Please write new method as shown below to get records from staging and delete.

public static void postGetStagingData(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
while select forupdate headerStaging
where headerStaging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId
&& headerStaging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup
{

}
}

20 August 2018

Deploy SSRS reports using powershell in Dynamics 365 Finance and Operations

Run power shell as an admin and run below command (change path if needed) J:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “J:\AosService\PackagesLocalDirectory”

08 August 2018

X++ code to release product in AX 2012 | D365

static void ReleaseProducts_detailed(Args _args)
{
EcoResProduct ecoResProduct;
InventTable inventTable;
InventTableModule inventTableModule;
NumberSequenceTable numberSequenceTable;
ItemId itemId;
InventItemSetupSupplyType inventItemSetupSupplyType;

EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
;

select firstOnly ecoResProduct where EcoResProduct.DisplayProductNumber == "20003"; //Audio system

changecompany ('RAX')
{
ttsBegin;
inventTable = null;
inventTableModule = null;
inventItemSetupSupplyType = null;
ecoResStorageDimensionGroupProduct = null;
ecoResTrackingDimensionGroupProduct = null;
ecoResStorageDimensionGroupItem = null;
ecoResTrackingDimensionGroupItem = null;

numberSequenceTable = InventParameters::numRefItemId().numberSequenceTable();
//get item id from:
//1. Product number if number seq for item ID is not set up or manual or return blank value
if (!numberSequenceTable.RecId || numberSequenceTable.Manual)
{
itemId = ecoResProduct.productNumber();
}
else //number sequence auto, get a number
{
itemId = NumberSeq::newGetNumFromId(numberSequenceTable.RecId).num();
}

inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = ItemId;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);

// Create inventTableModules

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.insert();

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.insert();

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.insert();

//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);

// Creates a new item default order type for the product that is released.

inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();

//create relationship tables to dimension groups.

ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProduct.RecId);
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProduct.RecId);

if (ecoResStorageDimensionGroupProduct.RecId)
{ // mandatory storage dimension group for the product
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
ecoResStorageDimensionGroupItem.insert();
}

if (ecoResTrackingDimensionGroupProduct.RecId)
{ // mandatory tracking dimension group for the product
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
ecoResTrackingDimensionGroupItem.insert();
}
ttsCommit;
info(strfmt("Product successfully released to ‘RAX’ legal entity"));
}
}

how to compare the date field in query | Date query range in AX 2012 | how to add date query range in ax 2012

how to compare the date field in query | Date query range in AX 2012 | how to add date query range in ax 2012
How to set range with Date field with Date value in AX 2012

queryBuildRange.value(strFmt('(ModifiedDate <= %1)', Date2StrXpp(01\01\2000))); // in this example ModifiedDate is query Range field what we are adding. Another example: queryBuildDataSource = query.addDataSource(tablenum(PriceDiscTable)); queryBuildDataSource.addRange(fieldNum(PriceDiscTable,FromDate)).value(strFmt("FromDate<=%1",toDate)); queryBuildDataSource.addRange(fieldNum(PriceDiscTable,ToDate)).value(strFmt("ToDate>=%1",toDate));


Perfect solution is:

public void lookup(FormControl _formControl, str _filterStr)

{

SysTableLookup sysTableLookup;

//Query query = new Query();

//QueryBuildDataSource queryBuildDataSource;

//QueryBuildRange queryBuildRange,queryBuildRangeFrom,queryBuildRangeTo;

//date toDate = today();



PriceDiscTable PriceDiscTable;

QueryRun QueryRun;

Query Query;

QueryBuildDataSource qbds;

QueryBuildRange qbr;



TransDate todaydate;

todaydate = systemDateGet();



super(_formControl, _filterStr);



sysTableLookup = SysTableLookup::newParameters(tablenum(PriceDiscTable), _formControl);



sysTableLookup.addLookupfield(fieldnum(PriceDiscTable, ItemRelation));

sysTableLookup.addLookupfield(fieldnum(PriceDiscTable, relation));

sysTableLookup.addLookupfield(fieldnum(PriceDiscTable, AccountRelation));





Query = new Query();

qbds = Query.addDataSource(tableNum(PriceDiscTable));

qbds.addSortField(fieldNum(PriceDiscTable,todate),SortOrder::Descending);

qbr = SysQuery::findOrCreateRange(qbds,fieldNum(PriceDiscTable,Fromdate));

qbr.value('<='+SysQuery::value(todaydate)); qbr = SysQuery::findOrCreateRange(qbds,fieldNum(PriceDiscTable,todate)); qbr.value( strfmt('((%1 = %2) || (%3 > %4))',fieldStr(PriceDiscTable,ToDate),date2strXPP(datenull()),fieldStr(PriceDiscTable,ToDate),date2StrXPP(todaydate)));



qbr = SysQuery::findOrCreateRange(qbds,fieldNum(PriceDiscTable, AccountRelation));

qbr.value(queryValue(sfcorderguidemaster::find(sfcorderguideitemmaster.Orderguideid).PriceGroup));


qbds.addGroupByField(fieldnum(PriceDiscTable, ItemRelation));

qbds.addGroupByField(fieldnum(PriceDiscTable, ItemCode));

qbds.addGroupByField(fieldnum(PriceDiscTable, AccountRelation));

//add the query to the lookup form

sysTableLookup.parmQuery(query);

// Do the lookup

sysTableLookup.performFormLookup();

}

31 July 2018

Converting time zones from Database time zone to Preferred time zone in AX 2012

utcDateTime Functionality in Dynamics AX 2012


utcDateTime localDateTime;

localDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());


Below is the reference link to get more idaa

26 July 2018

How to create contact for Customer or vendor in AX 2012 AX7 D365


DirParty dirParty;
DirPartyContactInfoView contact;
CustTable custTable;


custTable = CustTable::find(sfcCustRelation.AccountNum);
dirParty = DirParty::constructFromCommon(custTable);
contact.CountryRegionCode = CompanyInfo::find().DEL_CountryRegionId;
contact.LocationName = sfcCustRelation.Name;
contact.Locator = sfcCustRelation.EmailId;
contact.Type = LogisticsElectronicAddressMethodType::Email;
contact.ValidFrom = DateTimeUtil::getSystemDateTime();
//contact.ValidTo = DateTimeUtil::getSystemDateTime();//datetobeginUtcDateTime(1\1\2154, DateTimeUtil::getUserPreferredTimeZone()) ;
contact.Party = custTable.Party;
dirParty.createOrUpdateContactInfo(contact);

How to get contact informtaion for customer in AX 2012 AX 7 D365

CustTable custTable;
DirPartyTable dirParty;
LogisticsElectronicAddress electronicAddress;
DirPartyLocation dirPartyLoc;

//find the customer
custTable = CustTable::find("008");
//find the party for the customer
dirParty = DirPartyTable::findRec(custTable.Party);

//find all of the contacts for the current customer
while SELECT * FROM electronicAddress
EXISTS JOIN * FROM dirPartyLoc
WHERE electronicAddress.Location == dirPartyLoc.Location
&& dirParty.RecId==dirPartyLoc.Party
&& electronicAddress.Type == LogisticsElectronicAddressMethodType::Email
&& electronicAddress.Locator == "Test2Email@gmail.com"
{

info(electronicAddress.Locator);
}

23 July 2018

Dirparty table Contact person name Table structure and To make Contact person primary automatically for email in AX 2012 AX 7 D365


CustTable (Party)
DirPartyTable(RecId)
DirPartyLocation(Party)
LogisticsLocation(RecId)
LogisticsElectronicAddress(Location)



public void modified()
{
DirPartyLocation partyLocation;
LogisticsElectronicAddress electronicAddress;

super();


select partyLocation
where partyLocation.Party == custTable.Party &&
partyLocation.IsPrimary == true
exists join electronicAddress
where electronicAddress.Location == partyLocation.Location
&& electronicAddress.Type == LogisticsElectronicAddressMethodType::Email;


if( ! partyLocation.RecId)
{
DirPartyLocation_Electronic.IsPrimary = NoYes::yes;
}
else
{
DirPartyLocation_Electronic.IsPrimary = NoYes::No;
}

}

12 July 2018

Table method in extension AX 7 / D365 Extend the table in a new method / add a method in standard table in D365

Below is the method created a new method in CustGroup table using extension concept in D365

[ExtensionOf(tableStr(CustGroup))]
Final class TRCustGroup_Extension
{
public Static void method1(CustGroup _custGroup)
{
info(strFmt("Table method using extension , Cust group id %1",_custGroup.CustGroup));
}
}
===========
[ExtensionOf(tableStr(InventTable))]
final class InventTable_Extension
{
    public static boolean isMyFieldEmpty(InventTable _this)
    {
        return _this.MyExtField == '' ? true : false;
    }

}

Table Events and Event handlers in AX 7 / D365

Below example is to create Pre and post event handler for Existing method and second method is a new override method in the CustGroup Table.
class TRCustGroupEventHandler
{

///
///
///

/// [PreHandlerFor(tableStr(CustGroup), tableMethodStr(CustGroup, delete))]
public static void CustGroup_Pre_delete(XppPrePostArgs args)
{
CustGroup custGroup = args.getThis() as CustGroup;
//custGroup.cut
}

///
///
///

/// /// [DataEventHandler(tableStr(CustGroup), DataEventType::ValidatingWrite)]
public static void CustGroup_onValidatingWrite(Common sender, DataEventArgs e)
{
CustGroup custGroup = sender as CustGroup;
}

///
///
///

/// /// [DataEventHandler(tableStr(CustGroup), DataEventType::ValidatedField)]
public static void CustGroup_onValidatedField(Common sender, DataEventArgs e)
{
CustGroup custGroup = sender as CustGroup;
ValidateFieldValueEventArgs ve = e as ValidateFieldValueEventArgs;
boolean ret = ve.parmValidateResult();

if(ret)
{
switch(ve.parmFieldName())
{
case fieldStr(CustGroup,CustGroup):
if(custGroup.CustGroup == "")
{
ret = false;
}
break;
}
}

ve.parmValidateResult(ret);
}
}

10 July 2018

How to get the postal address location name in AX 2012 / AX 7 / D365

Below is the code to get the location name:

LogisticsLocation::find(CustTable.postalAddress().Location).Description

How to Display Page Number in Report Body of SSRS / AX 2012 / AX 7 / D365

Go to "Report" -> "Report Properties" -> "Code"

In the Custom Code section, enter the following:

Public Function PageNumber() as String
Dim str as String
str = Me.Report.Globals!PageNumber.ToString()
Return str
End Function

Public Function TotalPages() as String
Dim str as String
str = Me.Report.Globals!TotalPages.ToString()
Return str
End Function


Body - Expression

="Page " + Code.PageNumber() + " of " + Code.TotalPages()

05 July 2018

D365: AX 7: Delegate - How to create and use delegate in Dynamics 365

D365: AX 7: Delegate - How to create and use delegate in Dynamics 365
How to return value in Deligate and Event handler methods.

class TestPrintMgmtDelegateHandler
{
///
///
///

/// /// [SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
public static void PrintMgmtDocType_getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
{
if (_result.result() != null)
return;

_result.result(VCPrintMgmtDelegateHandler::getDefaultReportFormat(_docType));
}

///
///
///

private static PrintMgmtReportFormatName getDefaultReportFormat(PrintMgmtDocumentType _docType)
{
#ISOCountryRegionCodes

switch(_docType)
{
case PrintMgmtDocumentType::SalesOrderInvoice:
if(SysCountryRegionCode::isLegalEntityInCountryRegion([#isoTH]))
{
return ssrsReportStr(VCDeliveryReport, Report);
}
}
return ssrsReportStr(SalesInvoice, Report);;
}

}

29 June 2018

Working with Queries 2 in AX 2012 and Dynamics 365

public Query queryBuild()
{
Query q;
QueryRun qr;
QueryBuildDataSource qbd,qbd1;

q = new Query();

qbd = q.addDataSource(TableNum(CustTable));
qbd1 = qbd.addDataSource(TableNum(CustTrans));
qbd1.addLink(fieldNum(CustTable, CustAccount), fieldNum(CustTrans, CustAccount));

return q;
}

public Query queryBuildHeader()
{
Query q;
QueryRun qr;
QueryBuildDataSource qbd,qbd1;

q = new Query();

qbd = q.addDataSource(TableNum(CustTable));

return q;
}

==
Query q = this.queryBuildHeader();

07 June 2018

How to get user input value in Controller class in AX 2012 D365


How to get user input value in Controller class in AX 2012 D365
How to get contract value and based on the user value condition run report design

class TestController extends SrsReportRunController
{
public static void main(Args _args)
{
TestController controller = new TestController();
controller.parmReportName(ssrsReportStr(StatementMan, report));
controller.parmArgs(_args);
controller.startOperation();
}

///
///
///

protected void preRunModifyContract()
{
TestStmtContract contract = this.parmReportContract().parmRdpContract() as TestStmtContract;
this.parmReportContract().parmReportName(this.getReportName(contract));
super();
}

private str getReportName(TestStmtContract _contract)
{
str reportNameLocal;

if (_contract.parmNoTrans()) // this is the user input value
{
reportNameLocal = ssrsReportStr(StatementMan, report1);
}
else
{
reportNameLocal = ssrsReportStr(StatementMan, report);
}

return reportNameLocal;
}

}

21 May 2018

04 May 2018

Form Data source field modifed event usage in D365 of AX7

Form Data source field modifed event usage in D365 of AX7

sender.datasource().object(fieldNum(LedgerParameters, Field)).enabled(false);

26 April 2018

Refresh from data source from class in AX7 / D365


Table tableBuffer;
FormDataSource formDataSource;
tableBuffer = _args.record();
formDataSource = FormDataUtil::getFormDataSource(tableBuffer);
formDataSource.research();

19 April 2018

X++ code to read CSV file in AX7 / D365

AsciiStreamIo file;
Array fileLines;
FileUploadTemporaryStorageResult fileUpload;
fileUpload = File::GetFileFromUser() as FileUploadTemporaryStorageResult;
file = AsciiStreamIo::constructForRead(fileUpload.openResult());
if (file)
{
if (file.status())
{
throw error("@SYS52680");
}
file.inFieldDelimiter(',');
file.inRecordDelimiter('\r\n');
}
container record;
while (!file.status())
{
record = file.read();
if (conLen(record))
{
info(strFmt("%1 - %2",conPeek(record,1),conPeek(record,2)));
}
}

22 March 2018

Update the vendor open trans to mark and update the amount in ax 2012 or AX 7 and D365


VendTransOpen vendTransOpenLoc;
VendTrans vendTransLoc;
SpecTransManager specTransManager;
boolean found;
SpecTrans specTransLoc;
CustVendOpenTransManager managerLoc = CustVendOpenTransManager::construct(ledgerJournalTrans);

select firstonly vendTransLoc
where vendTransLoc.Invoice == ledgerJournalTrans.Invoice
join firstonly vendTransOpenLoc
where vendTransOpenLoc.RefRecId == vendTransLoc.RecId;
specTransManager = SpecTransManager::construct(ledgerJournalTrans);
found = SpecTrans::existByRef(vendTransOpenLoc.DataAreaID,tableNum(VendTransOpen),vendTransOpenLoc.RecId);

if(found == false)
{
managerLoc.updateTransMarked(vendTransOpenLoc,NoYes::Yes);
ttsbegin;
specTransLoc = SpecTrans::findByRef(vendTransOpenLoc.DataAreaID,tableNum(VendTransOpen),vendTransOpenLoc.RecId,true);
specTransLoc.Balance01 = -ledgerJournalTrans.AmountCurDebit;
specTransLoc.update();
ttscommit;
}
else
{
warning(strFmt("%1 Record already marked.",ledgerJournalTrans.Invoice));
}

19 March 2018

How to get the form control access using event handler in D365 or AX7 How to enable or disable the field in the form level in D365 or AX7

How to enable or disable the field in the form level in D365 or AX7

CustTable custTable = sender.cursor(); // args.getThis() as CustTable;
FormDataSource custTable_ds = sender.formRun().dataSource(tablestr(CustTable);
FormRun element = sender.formRun();
FormControl myNewControl = element.design(0).controlName("myControl");
myNewButton.enabled(false);

=====

CustTable custTable = sender.cursor(); // args.getThis() as CustTable;
FormDataSource custTable_ds = sender.formRun().dataSource(tablestr(CustTable);
FormRun element = sender.formRun();
custTable_ds.object(fieldNum(CustTable,CustGroup)).enabled(false);

23 February 2018

21 February 2018

AX7 : D365 : How to merge ledger and financial dimensions using X++ code in AX 7 : D365

In D365 there is a new class for financial dimension merging. Return the default dimension id.

DimensionMerge

PurchLine::mergeDimension
{
return _dimensionMerge.merge(_primaryDefaultDimension, _secondaryDefaultDimension);
}
public DimensionDefault mergeDimension(
DimensionDefault _primaryDefaultDimension,
DimensionDefault _secondaryDefaultDimension = 0,
DimensionMerge _dimensionMerge = DimensionMerge::newFromTable(this,
this.companyInfo().RecId
)
)
{
return _dimensionMerge.merge(_primaryDefaultDimension, _secondaryDefaultDimension);
}


Below is the method where the parameters are passing and return final default dimension Id.

DimensionDefault mergedDimensionDefault;
DimensionCopy dimensionCopy;

// Now merge the dimensions
mergedDimensionDefault = LedgerDimensionDefaultFacade::serviceMergeDefaultDimensions(
_dimensionDefaultMap.DefaultDimension, // Values that are currently on the record
_defaultDimension1, // Input value 1
_defaultDimension2); // Input value 2

20 February 2018

MS SQL Server Database restore error "Database is in use"

Check this to skip this error: Close existing connections to destination database

D365 or AX7 events to get current record or other database record in form

[FormDataFieldEventHandler(formDataFieldStr(InventTransRegister, TmpInventDim, inventBatchId), FormDataFieldEventType::Validating)]
public static void inventBatchId_OnValidating(FormDataObject sender, FormDataFieldEventArgs e)
{
FormDataSource tmpInventDim_ds = sender.datasource();
InventDim tmpInventDim = tmpInventDim_ds.cursor();
TmpInventTransWMS tmpInventTransWMS = tmpInventDim_ds.formRun().dataSource("TmpInventTransWMS").cursor();

Info(strFmt("Batch number %1-%2-%3",tmpInventDim.inventBatchId,tmpInventTransWMS.ItemId, tmpInventTransWMS.InventDimId));
}

01 February 2018

AX7: D365: Deploy All SSRS reports manually using command prompt

To deploy all SSRS reports:

Open Windows PowerShell in the VM
Run this command:
K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation "K:\AosService\PackagesLocalDirectory"

Note: Depending on path in your virtual machine you can switch between K: or the appropriate drive.

To deploy single report use the below command in PowerShell:

K:>AosService>PackagesLocalDirectory>Plugins>AxReportVmRoleStartupTask>.\DeployAllReportsToSsrs.ps1 -PackageInstallLocation "K:\AosService\PackagesLocalDirectory" -Module ApplicationSuite –ReportName.Report

Note: Where ReportName.Report is your report name with its design.



To deploy specific reports through PowerShell:

To deploy report whose name starts from say “PSAProjInvoice”, use a command as below,

K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -Module ApplicationSuite -ReportName PSAProjInvoice*

31 January 2018

Data management – financial dimensions import in D365 / AX7 Define financial dimension formats for data entities

How to import financial dimension values in Sales order import using data entity.

AX > General ledge > Chart of accounts > Dimensions > Financial dimension configuration for integrating applications

After setting the default dimensions - We have to fill the values in Data entity tempalte as shown below.

Field name is: DEFAULTLEDGERDIMENSIONDISPLAYVALUE

Structure: DepartMent - CostCenter - Purpose

Values in Excel cell: Dept1-Cost1-pur1

12 January 2018

SYSOperation frame work and example and usage in AX 2012 and D365 opertions


Sys Operation frame work is uses the MVC(Model view control) and enable the option in to expose the method using SysentryPointAtrribute[True], SysOperationFrame work is using in , SSRS contract to get input from user, Custom services, and batch job



SysEntryPoint[] is absolute in D365 and explain how the sysOperation works in the following:

How this work:

Base classes:
SysOperationServiceController // This base class extends to the Controller class
SysOperationDataContractBase // This base class extends to the Contract class.
SysOperationAutomaticUIBuilder // This base class extends to the UI Builder class


public static void main(Args _args)
{
ConWHSVehicleGroupChangeController controller;
controller = new ConWHSVehicleGroupChangeController(
classStr(ConWHSVehicleGroupChange),
methodStr(ConWHSVehicleGroupChange,
Run),
SysOperationExecutionMode::Synchronous);
controller.startOperation();
}

==

public static void main(Args _args)
{
ConWHSVehicleGroupChangeController controller;
ConWHSVehicleTable vehicle;
switch (_args.dataset())
{
case tableNum(ConWHSVehicleTable):
vehicle = _args.record();
break;
}
if(vehicle.RecId == 0)
{
//Active buffer required.
throw error ("@SYS25821");
}
controller = new ConWHSVehicleGroupChangeController(
classStr(ConWHSVehicleGroupChange),
methodStr(ConWHSVehicleGroupChange,
Run),
SysOperationExecutionMode::Synchronous);
ConWHSVehicleGroupChangeContract contract;
contract = controller.getDataContractObject('_contract');
if(!contract)
{
//Function %1 was called with an invalid value
throw error (
strFmt("@SYS23264",
classStr(ConWHSVehicleGroupChangeController)));
}
contract.VehicleGroupId(vehicle.VehicleGroupId);
contract.VehicleId(vehicle.VehicleId);
controller.startOperation();
if(FormDataUtil::isFormDataSource(vehicle))
{
//This will call the table's data source's research
// method to refresh the data from the table.
// The true parameter will keep the current record
FormDataUtil::getFormDataSource(vehicle).research(true);
}
}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...