Tuesday, February 23, 2021

Model packages of D365fo

 Models of packages D365fo

In D365 we can create new model. These are the reference model packages. 

1 Application common

2 Application Foundation

3 Application Platform

4 Application suit

5 Application Workspace

6 Bank types

7 Calender

8 CaseManagement

9 Contactperson

10 CreditManagement

11 Currency

12 Dimensions

13 Directory

14 DOM

15 ElectronicReporting

16 EnterpriseAssetManagementAppSuit

17 EnterpriseAssetManagementlot

18 FinanceInsightsContract

19 FiscalBooks

20 GeneralLedger

21 Inbound TransportationManagement

22 Ledger

23 Measurement

24 Personnel

25 PersonnelCore

26 PersonnelManagement

27 Project

28 Project operations

29 Retail

30 RetailEod

31 SCMMobile

32 SourceDocumentation

33 SourceDocumentationTypes

34 Subledger

35 TAX

36 TAXEngine

37 TestEssentials

38 UnitOfMeasure

39 WMSAdvancemigration

Standard classes

Standard classes


 Sales Table Confirm:

/// <summary>


/// </summary>

[ExtensionOf(classStr(SalesConfirmJournalPost))]

internal final class SalesConfirmJournalPost_Extension

{

/// <summary>

/// Chain of Command; after posting, update reallocation records.

/// </summary>

protected void endPost()

{

next endPost();

//Try to write here

}

}

SalesPickingListJournalPost -- Picking

SalesPackingSlipJournalPost -- Paking

SalesInvoiceJournalPost -- Invoice.


Purchase Order receive :(Receipt list)

/// <summary>


/// </summary>

[ExtensionOf(classStr(Purchpackingslipjournalpost))]

internal final class Purchpackingslipjournalpost_Extension

{

/// <summary>

/// Chain of Command; after posting, update reallocation records.

/// </summary>

protected void endPost()

{

next endPost();

//Try to write here

}

}

PurchInvoiceJournalPost -- Invoice

PurchReceiptsListJournalPost -- ReceiptsList


Transfer Order receive :(Receipt list)

[ExtensionOf(classStr(InventTransferUpdReceive))]

final class InventTransferUpdReceive_Extension


commitLedger() method.


InventTransferUpdShip -- Ship

InventTransferUpdPick -- Pick.

Monday, February 22, 2021

Create service order In D365 using X++

 

Create service order In D365 using X++

static void serviceOrder(Args _args)

{

SMAServiceOrderTable sMAServiceOrdertable,serviceOrderTable;

SMAServiceOrderLine sMAServiceOrderline;

NumberSeq NumberSeq;


ttsBegin;

NumberSeq = NumberSeq::newGetNum(SMAParameters::numRefServiceOrderId(),true);


serviceOrderTable.ServiceOrderId = NumberSeq.num();


serviceOrderTable.CustAccount = 'US-002';


serviceOrderTable.ProjId = '000058';


//display Customer Name as Service Order Description

serviceOrderTable.Description = CustTable::find('US-002').name();


//insert Service Address

serviceOrderTable.updateCustAddress();

serviceOrderTable.StageId = 'Planning';

serviceOrderTable.insert();



sMAServiceOrderline.ServiceOrderId = serviceOrderTable.ServiceOrderId;

sMAServiceOrderline.initFromServiceOrder(serviceOrderTable.ServiceOrderId);


sMAServiceOrderline.ProjCategoryId="Car Audio";

sMAServiceOrderline.ServiceObjectRelationId="000021";

sMAServiceOrderline.ServiceObjectId="000002";

sMAServiceOrderline.ServiceTaskId="Inspector";

sMAServiceOrderline.insert();


info("work finished");

ttsCommit;

}

Keep Daxing!!

Quality order creation In D65fo using X++

 Quality order creation In D65fo using X++


static void Quality(Args _args)

{

InventQualityOrderTable inventQualityOrderTable;

NumberSeq NumberSeq;

InventQualityOrderId QualityOrderId;

InventDim inventDim;


NumberSeq=NumberSeq::newGetNum(InventParameters::numRefQualityOrderId());

NumberSeq.used();

QualityOrderId = NumberSeq.num();


ttsBegin;


inventDim.initValue();

inventDim.InventSiteId = "1";

inventDim.InventLocationId = "13";

inventDim = InventDim::findOrCreate(InventDim);

inventDim.insert();


inventQualityOrderTable.initValue();

inventQualityOrderTable.ReferenceType = InventTestReferenceType::Inventory;

inventQualityOrderTable.QualityOrderId = QualityOrderId;

inventQualityOrderTable.ItemId = "D0001";

inventQualityOrderTable.TestGroupId = "Concentrat";

inventQualityOrderTable.Qty = 0.002;

inventQualityOrderTable.InventDimId = "000072";

inventQualityOrderTable.insert();

ttsCommit;


if(InventQualityOrderTable.Qty)

{

info(strFmt("%1",inventQualityOrderTable.QualityOrderId));

}

}

Keep Daxing!!


Service Agreement creation using X++ In D365Fo

 Service Agreement creation using X++ In D365Fo


static void agreementlines(Args _args)

{

SalesTable salesTable;

SalesLine salesline ;

CustTable custTable;

numberseq numberseq;

SMAAgreementTable agreementheader;

SMAAgreementLine agreementlines;

//RetailTransactionTable retailso;

InventDim inventdim;



numberseq = numberseq::newgetnum(smaparameters::numrefagreementid());


numberseq.used();


agreementheader.agreementid = numberseq.num();


agreementheader.agreementdescription = salesLine.itemName();


agreementheader.projid = '000058';


agreementheader.agreementgroupid = 'Gold';

agreementheader.StartDate = systemDateGet();

agreementheader.EndDate= systemDateGet();


agreementheader.insert();


agreementlines.transactiontype = smatransactiontype::Item;

agreementlines.worker = hcmworker::findbyperson(dirpersonuser::find(salesline.createdby).personparty).recid;

agreementlines.projid = '000058';

agreementlines.agreementlinenum = 1;

agreementlines.Description='Project Items';

agreementlines.qty = salesline.salesqty;

agreementlines.projcurrencyid = CustTable::find(salesLine.CustAccount).Name();

agreementlines.startdate =systemDateGet();

agreementlines.enddate =systemDateGet();

agreementlines.projlinepropertyid = "prjbill";

agreementlines.ItemId='0002';

agreementlines.agreementid =agreementheader.agreementid;

agreementlines.projcategoryid = 'Car Audio';

agreementlines.initfromagreementline(agreementlines,true);

agreementlines.insert();



info(strFmt("%1",agreementheader.agreementid));

}

Keep Daxing!!

Create Transfer Order using X++ in d365fo

 Create Transfer Order using X++ in d365fo.


static void CreateTransferOrder(Args _args)

{

    inventTransferTable inventTransferTable;

    inventTransferLine inventTransferLine;

    numberSequenceReference numberSequenceReference;

    numberSeq numberSeq;

    ProdBom   prodBom;

    InventTable  inventTable;

;

    ttsBegin;

    numberSeq = NumberSeq::newGetNum(InventParameters::numRefTransferId());

    inventTransferTable.clear();

    inventTransferTable.initValue();

   // inventTransferTable.TransferId='000021';


    inventTransferTable.TransferId = numberSeq.num();

    numberSeq.used();

    // inventTransferTable.InventDim

    inventTransferTable.InventLocationIdFrom = '11';

    inventTransferTable.modifiedField(fieldNum(InventTransferTable, InventLocationIdFrom));

    inventTransferTable.InventLocationIdTo = '13';

    inventTransferTable.modifiedField(fieldNum(InventTransferTable, InventLocationIdTo));

    inventTransferTable.TransferStatus = InventTransferStatus::Created;

    inventTransferTable.insert();


//Line

    inventTransferLine.clear();


    inventTransferLine.ItemId = 'D0001';

    inventTransferLine.initFromInventTable(InventTable::find('D0001'));

    inventTransferLine.initFromInventTransferTable(inventTransferTable, NoYes::Yes);

    inventTransferLine.QtyTransfer = 10;

    inventTransferLine.QtyShipNow = 10;

    inventTransferLine.QtyReceiveNow = 10;

    inventTransferLine.insert();

    ttsCommit;

    info(strFmt("%1",inventTransferTable.TransferId));

}


-----------or--------------------

static void CreateTransferOrderLine(Args _args)

{


InventTransferTable inventTransFerTable;

InventTransferLine inventTransFerLine;

InventTable inventTable;

NumberSeq numberSeq;

ttsBegin;

numberSeq = NumberSeq::newGetNum(InventParameters::numRefTransferId());


inventTransferTable.TransferId = numberSeq.num();

numberSeq.used();

inventTransferTable.InventLocationIdFrom = "13";

inventTransferTable.InventLocationIdTo = "11";


inventTransferTable.InventLocationIdTransit = InventLocation::find(inventTransferTable.InventLocationIdFrom).InventLocationIdTransit;

inventTransferTable.initFromAddress();

inventTransferTable.initValue();

inventTransferTable.initDeliveryMode();

inventTransferTable.initToAddress();

inventTransferTable.insert();

inventTransferLine.clear();


inventTransferLine.initFromInventTransferTable(inventTransferTable,NoYes::Yes);

inventTransferLine.ItemId = "D0001";

inventTransFerLine.LineNum = InventTransferLine::lastLineNum(inventTransferTable.TransferId) + 1;

inventTable = InventTable::find(InventTransferLine.ItemId);

inventTransferLine.initFromInventTable(InventTable);

inventTransferLine.QtyTransfer = 1.0;

inventTransferLine.QtyRemainReceive = 1.0;

inventTransferLine.QtyRemainShip = 1.0;

inventTransferLine.insert();

ttsCommit;

info(strFmt("%1",inventTransferTable.TransferId));

}

Keep Daxing!!

Block Inventory through code in D365fo


Block Inventory through code in D365fo


 static void inventBlocking(Args _args)

{

   InventBlocking   inventBlocking ;

    InventDim       inventDim;

;

    ttsBegin;

    InventBlocking.initValue();

    inventBlocking.Qty=0.5;

    inventBlocking.ItemId="D0001";

    inventDim.InventSiteId='1';

    inventDim.InventLocationId='11';

    inventBlocking.InventDimId=InventDim::findOrCreate(inventDim).inventDimId;

    inventBlocking.Description='inventory blocking';

    inventBlocking.insert();

    ttsCommit;

    info(strFmt('%1- %2',inventBlocking.Description, inventBlocking.ItemId));

}

Keep Daxing!!

Get default site and warehouse of item In D365fo

 

Get default site and warehouse of item In D365fo.

Check below job.

static void defaultSite(Args _args) { InventTable inventTable = inventTable::find('D0001'); InventItemOrderSetupType setupType = InventItemOrderSetupType::Invent; InventDim inventDim; ; // Default Site inventDim.InventSiteId = inventTable.inventItemOrderSetupMap( setupType).inventSiteId(inventDim.InventSiteId, inventTable); // Default Location inventDim.InventLocationId = inventTable.inventItemOrderSetupMap(setupType, InventDim::findOrCreate(inventDim).InventDimId) .inventLocationId(inventDim.InventLocationId, inventTable, inventDim.InventSiteId); inventDim = InventDim::findOrCreate(inventDim); }


Keep Daxing!!

How to De block the Item from Invent Block in D365fo

 Hi guys, Today we see How to De block  the Item from Invent Block in D365fo.


Check below job.

static void deBlock(Args _args)

{

 InventBlocking   inventBlocking ;

    InventDim       inventDim;


    inventDim.InventSiteId='1';

    inventDim.InventLocationId='11';

    inventDim = InventDim::findOrCreate(inventDim);

    

    select inventBlocking join inventDim

        where inventBlocking.ItemId=="Dax Sub 1"

        &&inventBlocking.InventDimId==inventDim.inventDimId

        && inventBlocking.Qty==3;


    ttsBegin;

    if (inventBlocking.BlockingType == InventBlockingType::Manual)

    {

        inventBlocking.selectForUpdate(true);

        inventBlocking.delete();

        info(strFmt('%1','del'));

    }

    ttsCommit;

}

Keep Daxing!!

Check If sales order amount is paid or not in D365fo

 Hi guys, Today we see how to Check If sales order amount is cleared or not in D365fo.


Check below job.

static void checkAmount(Args _args)

{

    CustInvoiceJour  inv;

    CustTrans   custTrans;

    Salestable    salestable;


    Select salestable

        join inv where salestable.SalesId == inv.SalesId

        && salestable.SalesId == '000691'

        && salestable.SalesStatus == SalesStatus::Invoiced

        join custTrans where custTrans.Voucher == inv.LedgerVoucher

        && custTrans.TransDate == inv.InvoiceDate

        && custTrans.AccountNum == inv.InvoiceAccount

        && custTrans.Invoice == inv.InvoiceId;


    info(strFmt('%1-%2-%3-%4',custTrans.remainAmountCur(),salestableloc.CustAccount,custTrans.Voucher,custTrans.Invoice));

    }


Keep Daxing!!

Saturday, February 6, 2021

Add customized code in sales order confirmation In D365FO

Add customized code in sales order confirmation  In D365FO 


Check below method.


[ExtensionOf(classStr(SalesConfirmJournalPost))]

internal final class TestSalesConfirmJournalPost_Extension

{

    /// <summary>

    /// Chain of Command; after posting, update reallocation records.

    /// </summary>

    protected void endPost()

    {

        next endPost();  

//Try to write here 

    }

}

Keep Daxing!!

Caller Form Name, Record from Called Form In D365FO

 Hi guys, Today we see how to get Caller Form Name, Record from Called Form In D365FO.


  • Caller form name:

        FormRun caller,formRun = sender.formRun();//FormControl(sender) childform     Args args = new Args();     ;     caller = sender.formRun().args().caller();     if(caller.args().name() == formStr(TestForm)

  • Caller data source name:

        element.args().dataset() == tableNum(CustTable)

  • Caller form menu item name:

            FormRun caller = sender.args().caller(); // xFormRun(sender) child form formrun

        caller.args().menuItemName() == menuItemDisplayStr(PIDInventSite))  

  • Get menu item name:

        element.args().menuItemName();

  • Get current record of caller form:
    • Way1 : 
                if (element.args().dataset() == tableNum(CustTable))
     {     CustTable custTable = element.args().record();
         }
    • Way2 : (Get Any data source current record)
               FormDataSource formDataSource;
FormRun caller; //caller form caller = element.args().caller(); if (caller.args().name() == formStr(MyForm)) { for (i = 0; i <= caller.dataSourceCount(); i++) { formDataSource = caller.dataSource(i); if (formDataSource && formDataSource.table() == tableNum(MyTable)) { MyTable myTableLoc = formDataSource.cursor(); break; } } }

Example:

Calling From Parent:

[FormControlEventHandler(formControlStr(TestForm, Test), FormControlEventType::Clicked)]
public static void Test_OnClicked(FormControl sender, FormControlEventArgs e)
{
    TableA            tableA= sender.formRun().dataSource().cursor() as TableA ;
    Args              args = new Args();
    FormRun          formRun;
    ;

    args.name(formStr(TestChild));
    args.record(tableA);
    args.caller(sender.formRun());

    formRun = classfactory.formRunClass(args);

    formRun.init();
    formRun.run();
    formRun.wait();
}

In child:


Form Init:

public void init() { super(); if (element.args().dataset() == tableNum(CustTable)) { CustTable custTable = element.args().record(); MyTable_ds.query().dataSourceTable(tableNum(MyTable)).addRange(fieldNum(MyTable,
                                                FieldName)).value(custTable.AccountNum); }
  

 
Ok button:

[FormControlEventHandler(formControlStr(TestChild, Ok), FormControlEventType::Clicked)] public static void Ok_OnClicked(FormControl sender, FormControlEventArgs e) { TableA tableA; FormRun caller,formRun = sender.formRun(); Args args = new Args(); ; caller = sender.formRun().args().caller(); if(caller.args().name() == formStr(TestForm)) { tableA= sender.formRun().args().record() as TableA ; info(strfmt('%1',tableA.Id)); } }

Keep Daxing!!

Wednesday, February 3, 2021

Based on security roles to enable or disable the Fields in a form in D365FO

 Hi guys, Today we see how to Based on security roles to enable or disable the Fields in a form in D365 FO.

Please check below code.

    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]

    public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

    {

        securityrole            role;

        securityuserrole        userrole;

        boolean                 check;

        

        select firstonly RecId from role

                    join userrole

                where role.recid == userrole.securityrole

                && role.name== 'Test'

                && userrole.user == curuserid();


        check = (role.recid ? true : false);


        sender.object(fieldNum(SalesTable, TestField)).allowEdit(check);

}


Keep Daxing!!