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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Vendor payment settlement with code

(0) ShareShare
ReportReport
Posted on by 66

Hi,

Recently I got the requirement to settle customer so I used the below code for example taken from blog

CUSTTABLE originator = CustTable::find(‘CAHM-1066’);
CustVendOpenTransManager SettleManager;
Custtransopen custtransopenfrom, custtransopento;
;
SettleManager = custVendOpenTransManager::construct(originator);

The originaor will be custtable however it gives me an error saying that it is expecting ledgerjournaltrans record

//finding debit amount record
select firstonly1 custtransopenfrom
where custtransopenfrom.AccountNum == originator.AccountNum
&& custtransopenfrom.RefRecId == 5637165579;

SettleManager.updateTransMarked(custtransopenfrom, true);
SettleManager.updateSettleAmount(custtransopenfrom, 200); 

SettleManager.settleMarkedTrans();

This is not creating any transaction in the customer transaction table
Has anyone worked on such thing.

I need to do same thing for the vendors too.

I have the same question (0)
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    First of all, let me make your code easier to read by using Insert > Code and fixing a few things:

    CustTable originator = CustTable::find('CAHM-1066');
    CustTransOpen custTransOpenFrom;
    
    //finding debit amount record
    select firstonly custTransOpenFrom
    	where custTransOpenFrom.AccountNum == originator.AccountNum
    	   && custTransOpenFrom.RefRecId == 5637165579;
    
    CustVendOpenTransManager settleManager = CustVendOpenTransManager::construct(originator);
    settleManager.updateTransMarked(custTransOpenFrom, true);
    settleManager.updateSettleAmount(custTransOpenFrom, 200); 
    settleManager.settleMarkedTrans();

    When you say "it gives me an error", which method are you talking about? You seem to suggest that CustVendOpenTransManager can handle only LedgerJournalTrans records, which isn't true, as far as I know. Using a CustTable record looks correct to me.

  • vicky1234 Profile Picture
    66 on at

    Thanks Martin for the code part .

    The thing is when I actually run the code it throws error saying Cannot cast from ledgerjournaltrans to custtable sort of error .

    I have debug this and on passing the ledgerjournaltrans it does not gives an error,

    However the major concern is that this piece of code is actually not doing anthing even after execution with ledgerjournaltrans.

    I want to settle the payments that is the main part that i am looking for.

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Which line of code does throw this error?

  • vicky1234 Profile Picture
    66 on at

    Hi MArtin.

    We found some custom code in the envirornment and I will check on that and update . Most probably it must be because of the customizations.

    I will update once I debug again.

    thanks for the reply.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans