Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Recalculate credit limit on customer

Posted on by 15

Hi,

I am trying to update CustTable with a credit limit from a CSV-file without any luck.

The check for the credit limit with the recalculation popup doesn't return the control and my batch job class stops.

Besides I don't get the popup at all like I did when using ttsbegin/ttscommit.

Also is it possible from my class (always, either run manually or in a batch) to NOT get the popup?

Does anyone know how the log works also, if I show something in the infolog will it be added to the job history?

This is my code. What is wrong?

//try
//{

//ttsbegin;

record = importFile.read();

while(importFile.status() == IO_Status::Ok)
{

record = importFile.read();

if(!record)
break;

custTable.clear();
custAccountNum = conPeek(record,2);
custTable = CustTable::find(custAccountNum,true);
if(custTable)
{
info(strFmt("Customer: %1", custTable.name()));
custCreditLimit = conPeek(record,4);
if(custTable.CreditMax != custCreditLimit) //Check Credit Limit
{

custTable.VATNum = conPeek(record,3);
custTable.CreditMax = custCreditLimit;
this.parmCreditLimit(custTable);
insDateTime = str2datetime(conPeek(record,5) ,321);
updDateTime = str2datetime(conPeek(record,6) ,321);
custTable.update();
}
}
else
{
info("Customer not found");
}

}

//ttscommit;

//}

//catch(Exception::Error)
//{
//Throw(Exception::Error);
//}

public void parmCreditLimit(CustTable _custTable)
{
MenuFunction salesCreditLimitCheck;
Args args;
CustCreditLimit custCreditLimit;
// CustCreditLimit custCreditLimit = new CustCreditLimit(CustTable::find(_custTable.AccountNum));

custCreditLimit = CustCreditLimit::construct(_custTable);
if (custCreditLimit.shouldCheckCreditAvailable() &&
_custTable.existOpenOrders())
{
//Updating estimated value for open sales orders related to the customer.
args = new Args();
args.parm(_custTable.AccountNum);
salesCreditLimitCheck = new MenuFunction(menuitemActionStr(salesCreditLimitCheck), MenuItemType::Action);
if (salesCreditLimitCheck.checkAccessRights())
{
salesCreditLimitCheck.run(args);
}
}
}

Regards Fredrik.

  • Fredrik Brandt Profile Picture
    Fredrik Brandt 15 on at
    RE: Recalculate credit limit on customer

    Hi and thanks,

    I had to rewrite the code a bit, but I created a batch-job from my import.

    Regards,

    /Fredrik.

  • Verified answer
    MuthukumaranAX Profile Picture
    MuthukumaranAX 2,897 on at
    RE: Recalculate credit limit on customer

    this object is available in D365 ideally it should be there in AX 2012 as well.

  • Fredrik Brandt Profile Picture
    Fredrik Brandt 15 on at
    RE: Recalculate credit limit on customer

    In AX2012?

  • MuthukumaranAX Profile Picture
    MuthukumaranAX 2,897 on at
    RE: Recalculate credit limit on customer

    Kindly check the logic written in the below object and you can follow the same approach

    CustTableChangeProposalApply (class) >> updateEstimatedValueOnSalesOrderRelatedToCustomer (method)

  • Fredrik Brandt Profile Picture
    Fredrik Brandt 15 on at
    RE: Recalculate credit limit on customer

    Yes, that is correct.

  • MuthukumaranAX Profile Picture
    MuthukumaranAX 2,897 on at
    RE: Recalculate credit limit on customer

    just to be clear, your requirement is to update the credit limit in the customer master at the same time recalculate the credit limit. correct?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans