how to sync FO custom field in D365 fo Retail Database

so i have a requirement to push extension field data to channel database so we can use in POS side.

for this what i have done is defined below

these are the custom field in D365 fo table.



to Push these field to retail I have created a custom table in FO in which we have the same custom field which we required in POS side .
this is the custom table contain all that custom field 
and save data per company is set to no
a custom field is created for dataareaId  due to some reasons.







After that create a code extention of CustParamter Table and did this code to insert and update data in Or custom table.



[ExtensionOf(tableStr(CustParameters))]

final class CustParameters_SIL_TUCustomizations_Extension

{


    void update()

    {

        next  update();


        this.createOrUpdateTUCustParametersExt(this);

    }


    public void createOrUpdateTUCustParametersExt(CustParameters _CustParameters)

    {


        TUCustParametersExt TUCustParametersExt;

        select * from TUCustParametersExt where TUCustParametersExt.RefRecid == this.RecId;


        if(TUCustParametersExt)

        {

            ttsbegin;

            TUCustParametersExt.selectForUpdate(true);


            TUCustParametersExt.TU_BaseURL =_CustParameters.TU_BaseURL; 

            TUCustParametersExt.TU_Email =_CustParameters.TU_Email;

            TUCustParametersExt.TU_FullName =_CustParameters.TU_FullName;

            TUCustParametersExt.TU_OrgId =_CustParameters.TU_OrgId;

            TUCustParametersExt.TU_Password =_CustParameters.TU_Password;

            TUCustParametersExt.TU_Role =_CustParameters.TU_Role;

            TUCustParametersExt.Key =_CustParameters.Key;

            TUCustParametersExt.CompanyId =_CustParameters.DataAreaId;

            TUCustParametersExt.update();

            ttscommit;

        

        }

        else

        {

            TUCustParametersExt.TU_BaseURL =_CustParameters.TU_BaseURL;

            TUCustParametersExt.TU_Email =_CustParameters.TU_Email;

            TUCustParametersExt.TU_FullName =_CustParameters.TU_FullName;

            TUCustParametersExt.TU_OrgId =_CustParameters.TU_OrgId;

            TUCustParametersExt.TU_Password =_CustParameters.TU_Password;

            TUCustParametersExt.TU_Role =_CustParameters.TU_Role;

            TUCustParametersExt.RefRecid =_CustParameters.RecId;

            TUCustParametersExt.Key =_CustParameters.Key;

            TUCustParametersExt.CompanyId =_CustParameters.DataAreaId;

            TUCustParametersExt.insert();

        

        }


    

    }


}



after that create the same table in channel database like this




now we need to link the custom pos table and FO table for this we need to create an xml file like this

<RetailCdxSeedData ChannelDBMajorVersion="7" ChannelDBSchema="ext" Name="AX7">

   <Jobs>

   </Jobs>

   <Subjobs>

       <Subjob Id="TUCustParameterSeedData" TargetTableSchema="ext" AxTableName="TUCustParametersExt" TargetTableName="TUCustParametersExt">

           <ScheduledByJobs>

               <ScheduledByJob>1110</ScheduledByJob>

           </ScheduledByJobs>

           <AxFields>

               <Field Name="KEY"/>

               <Field Name="CompanyId"/>

               <Field Name="TU_EMAIL"/>

               <Field Name="TU_PASSWORD"/>

               <Field Name="TU_FULLNAME"/>

               <Field Name="TU_ORGID"/>

               <Field Name="TU_ROLE"/>

               <Field Name="TU_BASEURL"/>

               <Field Name="REfRECID"/>

               <Field Name="RECID"/>

            </AxFields>

       </Subjob>

   </Subjobs>

</RetailCdxSeedData>





after that we need to do create a resouse file in FO and attach that xml with it 



than we need to create event handler class

inside that pasted this method


    [SubscribesTo(classStr(RetailCDXSeedDataBase), delegateStr(RetailCDXSeedDataBase, registerCDXSeedDataExtension))]

    public static void RetailCDXSeedDataBase_registerCDXSeedDataExtension_TU(str originalCDXSeedDataResource, List resources)

    {

        if (originalCDXSeedDataResource == resourceStr(RetailCDXSeedDataAX7))

        {

            //4 march 2026 added to get sms Credential in POS (Custom Fields)

            resources.addEnd(resourceStr(TUCustParameterExtCDXSeedDataAX7_Extenstion));

        }


    }


replace your resource file name instead of "TUCustParameterExtCDXSeedDataAX7_Extenstion"   
in above method.



than build this and go to FO and run 

Initialize commerce scheduler

after that you to run your Distribution schedules defined in the xml in my case it is 1110

than your data will be sync in channel table



Regards 

Muhammad Farraz
farazjaved01@gmail.com

Comments

Popular posts from this blog

step 20 Update script for service model: AOSService on machine: CR-VM-Test-1

create movement journal through code in d365 FO x++