Enter the key words to find the related topics

Composite Entity in D365


Create new project from Visual Studios.

Navigate to File->New->Project.

Name it as CR_CustomEntity.

Navigate to Solution Explorer, right click on Project, select New Item under Add.

Select Table under Data Model (Operations Artifacts).

Name it as DICustTable.

Add two fields
  • ID(string)
  • Name(string)
Create Index name it as IDX, add ID field in that.

Change Primarykey property to IDX .



Now create second table name it as DICustInfo.

Add two fields.
  •  ID
  • Address
Create Index name it as IDX, add ID field in that.

Change Primarykey property to IDX .

Create Normal relation name it as DICustTable, as shown below.


Set the properties as shown below.






Now right on DICustTable, select Create data entity under Add-ins, as show below.



After clicking , staging table, security privileges, entity are created.

Table
  • DICustTableStaging
Security privileges
  • DICustTableEntityMaintain
  • DICustTableEntityView
Data Entities
  • DICustTableEntity

Now Similarly, do for DICustInfo same as DICustTable.

After completion  staging table, security privileges, entity are created.

Table
  • DICustInfoStaging
Security privileges
  • DICustInfoEntityMaintain
  • DICustInfoEntityView
Data Entities
  • DICustInfoEntity

See below picture for clear image.



Now create below two fields in two Staging tables(DICustTable, DICustInfo)

  • RowId(Integer)
  • ParentRowId(Integer)
Now create new foreignKeyRelation on DICustInfoStaging table, add field relations as shown below.




 Set below properties




Now navigate to solution explorer, right click select new item under Add.

Select Composite Data Entity under Data Model (Operations Artifacts).

Name it as DICompositeEntity.

Now right click on DICompositeEntity, select New Root  Data Entity Reference



Set the below properties.


Now again right click on DICustTableEntity, select New Embedded Data Entity Reference, set the below properties.




Now you can Import and Export from User Interface .





Post Button enabling and disabling for Journals.

Payment Journal
First Form




Journal Vocher
Second Form




For First form follow below steps:

Steps:

1. Navigate to  Classes\LedgerJournalFormTable\enableButtonActive and write below code.

UserGroupInfo        userGroupInfo;
UserGroupList        userGroupList;
boolean                   postButtonEnable;

select name from userGroupInfo
      where userGroupInfo.name =='Post Group'
                join groupId,RecId,UserId from userGroupList
      where userGroupList.groupId == userGroupInfo.name
               && userGroupList.userId == curUserId();
if (userGroupList.RecId)
{
     postButtonEnable = true;
}
else
{
    postButtonEnable = false;
}
2. Now Add postButtonEnable in IF ELSE Condition which is shown in BOLD  FONTS and Highlighted with yellow background color.

if (ctrlPostJournalMenu)
{
     if (!this.journalTable_DS().anyMarked())
    {
      if (ledgerJournalTable.isInWFApprovalProcess())
     {
         // The journal is in workflow approvals.
         ctrlPostJournalMenu.enabled(enabled && !ledgerJournalTable.Posted &&       ledgerJournalTable.isWFApprovalApproved());
     }
     else
    {
       // The is not in workflow approvals.
         ctrlPostJournalMenu.enabled(enabled && !ledgerJournalTable.Posted && ledgerJournalTable.approved() && postButtonEnable);
    }
 }


For Second form follow below steps:

Steps:

1. Navigate to  Classes\LedgerJournalFormTrans\setPostMenuButtonEnabled and write below code.

UserGroupInfo        userGroupInfo;
UserGroupList        userGroupList;
boolean                   postButtonEnable;

select name from userGroupInfo
      where userGroupInfo.name =='Post Group'
                join groupId,RecId,UserId from userGroupList
      where userGroupList.groupId == userGroupInfo.name
               && userGroupList.userId == curUserId();
if (userGroupList.RecId)
{
     postButtonEnable = true;
}
else
{
    postButtonEnable = false;
}
2. Now Add postButtonEnable in IF ELSE Condition which is shown in BOLD  FONTS and Highlighted with yellow background color.  

if (ctrlPostJournalMenu)
{
    enabled = this.isJournalEnabled();
    if (ledgerJournalTable.isInWFApprovalProcess())
    {
       enabled = enabled && ledgerJournalTable.isWFApprovalApproved();
    }
   else
   {
       enabled = enabled && ledgerJournalEngine.approved() &&   postButtonEnable ;
   }
ctrlPostJournalMenu.enabled(enabled);
}