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:-
[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