Wednesday, October 18, 2023

customer Change Proposal

How to achieve customer approval through custom code in X++.

First, I am creating a custom field in the 'custTable' Table, and the field is of enum type.


EnumField:-

I am taking a base enum extension, and in this extension, I am performing a drag-and-drop our custom base enum.
That field reflact to the custparameters form




Field is dragging and dropping the field onto the 'custTable' table and form ..
I am creating another field named 'ischangeddaxteamId' on the 'customer change proposal' table. I've also dragged and dropped the 'DaxTeam' base enum onto the 'customer change proposal' table.
The standard group control in the 'cust change proposal' form is the same as what I am creating with another group.


Code:-

[ExtensionOf(formDataFieldStr(custtable,custtable,DAXTeam))]

internal final class DAXCustTableFormControal_Extension

{

   public void modified()

   {

       FormDataObject formDataObject = any2Object(this) as FormDataObject;

       FormDataSource formDataSource = formDataObject.datasource();

       FormRun formRun = formDataSource.formRun();

       CustTable   custTable = formDataSource.cursor();

       formRun.showCustChangeProposalDialog();

       formRun.modifiedControlledField(

                   fieldNum(CustTable, DAXTeam),

                   fieldNum(CustTableChangeProposal, DAXTeam),

                   custTable,

                   CustTableChangeProposalField::DAXTeam);

       next modified();

   }

}

---------------------------------------------

[ExtensionOf(formStr(CustTable))]

internal final class DAXCustTableFrom_Extension

{

   public void markChangeProposalFields()

   {

    

       next markChangeProposalFields();

       if (CustTableChangeProposalFieldEnablement::isEnabledFor(CustTableChangeProposalField::DAXTeam))

       {

           CustTable_DAXTeam.label(strFmt(

               "@AccountsReceivable:FieldLabelMarkingInBrackets",

               custTable_ds.object(fieldNum(CustTable, DAXTeam)).labelText(),

               "@AccountsReceivable:FieldLabelMarkingRequiresApproval"));

       }

   } 

}

--------------------------------------

[ExtensionOf(tableStr(CustTableChangeProposal))]

internal final class CustTableChangeProposalTable_Extension

{

   public void setFlagForChangedField(CustTableChangeProposalField _controlledField)

   {

       next setFlagForChangedField(_controlledField);

       switch (_controlledField)

       {

           case CustTableChangeProposalField::DAXTeam :

               this.IschangedDaxTeamId = NoYes::Yes;

               break;

       }

   }

}

------------------------------------------

[ExtensionOf(tableStr(CustTableChangeProposalFieldEnablement))]

internal final class DAXCustableChangeProposalFieldEnablementTable_Extension

{

   public static void initializeAll()

   {

       next initializeAll();

       CustTableChangeProposalFieldEnablement::findOrCreate(CustTableChangeProposalField::DAXTeam);

 

   }

}

---------------------------------------------

[ExtensionOf(formStr(CustChangeProposal))]

internal final class DAXCustChangeProposalForm_Extension

{

   public void showHideGroups()

   {

       FormRun formRun = this as FormRun;

       FormDataSource  fds = this.dataSource();

       next showHideGroups();

       FormGroupControl DAXTeamGroup = formRun.design().controlName(formControlStr(CustChangeProposal, DAXTeamGroup)) as FormGroupControl;

       CustTableChangeProposal custTableChangeProposal = fds.cursor();

       DAXTeamGroup.visible(custTableChangeProposal.IschangedDaxTeamId);

   }

 

   protected void disableDiscardButtons()

   {

       FormRun formRun = this as FormRun;

       FormButtonControl DAXTeamButton = formRun.design().controlName(formControlStr(CustChangeProposal, DAXTeamButton)) as FormButtonControl;

       next disableDiscardButtons();

       DAXTeamButton.enabled(false);

   }

 

}

-----------------------------------------------------

[ExtensionOf(formControlStr(CustChangeProposal,DAXTeamButton))]

internal final class DAXCustChangeProposalControl_Extension

{

   public void clicked()

   {

       FormbuttonControl                 callerButton    = any2Object(this) as FormbuttonControl;

       FormRun                     formRun         = callerButton.formRun();

       FormDataSource              formDataSource  = formRun.datasource();

       CustTableChangeProposal     custTableChangeProposal = formDataSource.cursor();

       

       ttsbegin;

       CustTableChangeProposal localRecord = CustTableChangeProposal::findByCustRecId(CustTableChangeProposal.CustTable, true);

       localRecord.IschangedDaxTeamId = NoYes::No;

       localRecord.update();

       ttscommit;

       next clicked();

   }

 

}

====================================================

Output:-

Account Receivable--> set up--->Account receivable parameter.

I am changing the values as shown in the figure below.

Account Receivable-->all customers---->slect particular customer















No comments:

Post a Comment

My Requirement is Delete option in Vendor Master for all roles except System Administrator

   [FormControlEventHandler(formControlStr(VendParameters, VendParameters_YNV_VendorMasterDeletionOption), FormControlEventType::Modified)] ...