Monday, January 6, 2025

Search hierarchy for a match (TableALLGroup) X++

  Table1 ppt;


 select firstonly ppt

 order ItemCode, ItemRelation, AccountCode, AccountRelation where

     (ppt.ItemCode == TableGroupAll::Table && ppt.ItemRelation == _itemId &&

         ppt.AccountCode == TableGroupAll::Table && ppt.AccountRelation == _accountNum) ||

     (ppt.ItemCode == TableGroupAll::Table && ppt.ItemRelation == _itemId &&

         ppt.AccountCode == TableGroupAll::GroupId && ppt.AccountRelation == _accountGroup) ||

     (ppt.ItemCode == TableGroupAll::Table && ppt.ItemRelation == _itemId &&

         ppt.AccountCode == TableGroupAll::All && ppt.AccountRelation == '') ||


     (ppt.ItemCode == TableGroupAll::GroupId && ppt.ItemRelation == _ItemGroup &&

         ppt.AccountCode == TableGroupAll::Table && ppt.AccountRelation == _accountNum) ||

     (ppt.ItemCode == TableGroupAll::GroupId && ppt.ItemRelation == _ItemGroup &&

         ppt.AccountCode == TableGroupAll::GroupId && ppt.AccountRelation == _accountGroup) ||

     (ppt.ItemCode == TableGroupAll::GroupId && ppt.ItemRelation == _ItemGroup &&

         ppt.AccountCode == TableGroupAll::All && ppt.AccountRelation == '') ||


     (ppt.ItemCode == TableGroupAll::All && ppt.ItemRelation == '' &&

         ppt.AccountCode == TableGroupAll::Table && ppt.AccountRelation == _accountNum) ||

     (ppt.ItemCode == TableGroupAll::All && ppt.ItemRelation == '' &&

         ppt.AccountCode == TableGroupAll::GroupId && ppt.AccountRelation == _accountGroup) ||

     (ppt.ItemCode == TableGroupAll::All && ppt.ItemRelation == '' &&

         ppt.AccountCode == TableGroupAll::All && ppt.AccountRelation == '');


 // Return table buffer if found, otherwise return 0 as the default

 if (ppt.RecId)

 {

     // return result

 }

Thursday, January 2, 2025

Create call center channel users X++ D365FO

 RetailChannelTable   channelTable;

MCRChannelUser      channelUser;


while select channelTable

    where channelTable.ChannelType ==  RetailChannelType::MCRCallCenter

{

    channelUser.clear();

    changecompany(channelTable.DefaultCustDataAreaId)

    {

        channelUser = MCRChannelUser::find();


        if(!channelUser)

        {

            channelUser.clear();

            channelUser.initValue();

            channelUser.Channel = channelTable.RecId;

            channelUser.User = curUserId();

            channelUser.insert();

        }

    }           

}

Search hierarchy for a match (TableALLGroup) X++

  Table1 ppt;  select firstonly ppt  order ItemCode, ItemRelation, AccountCode, AccountRelation where      (ppt.ItemCode == TableGroupAll::T...