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 :
Microsoft Dynamics AX (Archived)

The '_custAccount' argument is incompatible with the required type.

(0) ShareShare
ReportReport
Posted on by 30

Hi,

The following code gives me the error '_custAccount' argument is incompatible with the required type.

public boolean modified()
{
boolean ret;

ret = super();

CustTable.PdsCustRebateGroupId =CustTable::find(CustTable.AccountNum).PdsCustRebateGroupId;
//CustPaymModeTable.PaymMode =CustPaymModeTable::find(CustPaymModeTable.).PaymMode;
CustTable.Blocked =CustTable::find(CustTable.AccountNum).Blocked;
CustTable.PdsCustRebateGroupId =CustTable::find(CustTable.AccountNum).PdsCustRebateGroupId;
CustTable.PaymSched =CustTable::find(CustTable.AccountNum).PaymSched;
CustTable.CreditMax =CustTable::find(CustTable.AccountNum).CreditMax;
CustTable.PriceGroup =CustTable::find(CustTable.AccountNum).PriceGroup;
CustTable.PaymMode =CustTable::find(str(this.AccountNum)).PaymMode;

return ret;
}

Please, help me.
Thank You.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Which line of code gives that error? Most likely this one?

    CustTable.PaymMode =CustTable::find(str(this.AccountNum)).PaymMode;

    What is that "str" function supposed to do?

    Additionally, why are you performing CustTable::find so many times? You could just read it once from the database and have smaller performance cost. And, since you seem to be initializing a lot of fields from one cust table buffer to another, I would suggest you to have a separate method for this, in a class or a table, instead of having so much code in modified method. Now you can't reuse this code, and also you're adding payload on the client side, instead of running it on the server.

  • Yassine Fallate Profile Picture
    30 on at

    Hi Nikolaos Mäenpää

    it's just attempts to raise this error _custAccount' argument is incompatible with the required type

    so I want to retrieve information from a customer by a selection in a list of choices

    Look at the comments here for probleme origin

    community.dynamics.com/.../772146

    thank you for your reply

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Yes but from which line of your code does that error raise? Do you get the error when you save/compile your code, or when you execute it?

    If it comes from the compiler, you will see right away the line highlighted in red.

    If it comes from execution, try to click the error message on your infolog, then "Edit" button should apper, and it will take you to the code line where the problem is. Let us know what the line is.

    What is the data type of "this.AccountNum"?

    But, based on the other thread that you linked, could you tell us what are you trying to do with this form? Do you want to show some customer information to the user? Do you want to allow the user to update them? Or do you want to copy settings from one customer to another?

  • Yassine Fallate Profile Picture
    30 on at

    it's line number  14: CustTable.PaymMode = CustTable :: find (CustTable.AccountNum) .PaymMode;

    when I put this to place

    CustTable.PaymMode = CustTable :: find (str (this.AccountNum)). PaymMode;

    for the type of fields it's string

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I'm still not sure I understand.

    You are not providing enough information.

    Remove this line:

    CustTable.PaymMode = CustTable :: find (str (this.AccountNum)). PaymMode;

    Replace it with this line:

    CustTable.PaymMode = CustTable :: find (CustTable.AccountNum) .PaymMode;

    It should work. But because I don't know what is "this.AccountNum" I can't be sure if it works the way you want. What is the reason why you implemented that line with a different logic than the other ones?

    And  please consider my previous comments about the overall design of your feature.

  • Yassine Fallate Profile Picture
    30 on at

    my problem is : the time when i select the value of the customer's number normally the other information should change automatically in each field of the form

    thank you for quick reply

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

    It seems that you're trying to change AccountNum of an existing customer, which shouldn't be done. What exactly are you doing in the form?

    By the way, if calling find() is needed at all (which isn't clear yet), doing it repeatedly is a waste of resources. Call it just once and store the result in a variable. You code will be more efficient and easier to read and maintain.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans