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 64

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.

  • vicky1234 Profile Picture
    64 on at
    RE: Vendor payment settlement with code

    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.

  • Martin Dráb Profile Picture
    233,025 Most Valuable Professional on at
    RE: Vendor payment settlement with code

    Which line of code does throw this error?

  • vicky1234 Profile Picture
    64 on at
    RE: Vendor payment settlement with code

    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
    233,025 Most Valuable Professional on at
    RE: Vendor payment settlement with code

    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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,325 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans