web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / ELandAX blog / Create Customer Payment Jou...

Create Customer Payment Journal Using Payment Proposal Function from Code

Evaldas Profile Picture Evaldas 1,800
Hello Extension World,

This time we are going to create a customer payment journal using payment proposal function from code.
Executing functions from code can be a little bit trickier in this extension world.

First, let me explain what exactly we are going to do here.
  1. Open form Accounts payable\Payments\Payment journal
  2. Create a journal and go to the lines.
  3. Create one line and select a customer.
  4. Click button Payment proposal\Create payment proposal
  5. Fill in the dialog. Customer will be automatically selected from the line we created.
  6. In this example we will use Due date in the Select invoices by and set To date.
  7. Select all lines and click the button Create payments




Done.

The following code will execute the steps 3-7.

As an input we need LedgerJournalId and customer account. I guess you know how to create that so I can make my example simple.
We will also set PaymProposalType and ToDate parameters.


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    CustVendCreatePaymJournal_Cust   custVendCreatePaymJournal = CustVendCreatePaymJournal_Cust::construct();

Args argsPaymentProposal = new Args();
argsPaymentProposal.parmEnumType(enumNum(UserInteractive));
argsPaymentProposal.parmEnum(UserInteractive::Yes);

CustVendCreatePaymJournalDialogValues dialogValues = new CustVendCreatePaymJournalDialogValues();
dialogValues.parmAccountNum(custTable.AccountNum);
dialogValues.parmToDate(systemDateGet());
dialogValues.parmPaymProposalType(CustVendCreatePaymProposalType::DueDate);

custVendCreatePaymJournal.setLedgerJournalId(ledgerJournalTable.JournalNum);
custVendCreatePaymJournal.initNonUserInteractive(dialogValues);
custVendCreatePaymJournal.initUserInteraction(argsPaymentProposal);
custVendCreatePaymJournal.parmSkipProposalEditForm(NoYes::Yes);
custVendCreatePaymJournal.runOperation();

What you also need is to extend CustVendCreatePaymJournal_Cust class as there is no method to pass LedgerJournalId and initialize UserInteractive
Note: this will not be user interactive.


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[ExtensionOf(classStr(CustVendCreatePaymJournal_Cust))]
final class CustVendCreatePaymJournal_Cust_Extension
{
//Makes it possible to pass Ledger Journal Id
public void setLedgerJournalId(LedgerJournalId _ledgerJournalId)
{
this.parmLedgerJournalId(_ledgerJournalId);
}

//Makes it possible to instantiate userInteraction class
public void initUserInteraction(Args _args)
{
this.userInteraction(_args);
}
}

Here you go. Now you are ready.

Be aware and take care!

This was originally posted here.

Comments

*This post is locked for comments