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

Announcements

No record found.

News and Announcements icon
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 68

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
    239,451 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
    68 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
    239,451 Most Valuable Professional on at

    Which line of code does throw this error?

  • vicky1234 Profile Picture
    68 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 620

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 521 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans