Skip to main content



No record found.

Microsoft Dynamics AX forum

wrong type of argument for conversion function

Posted on by 131

I have create a form. I have write all my business logic in my newly created class. Problem is when I am calling class method in button clicked mthod then it is giving below error



here is my class code

public void parmmethod(str _brand, str _type,
    str _product,int _percentage,
    date _slabstart, date _slabend,
    SL_SchemeCode   _schemecode,
    int64 slabvaluestart, 
    int64 slabvalueend)

    brand = _brand;
    type = _type;
    product = _product;
    percentage = _percentage;
    slabstart = slabvaluestart;
    slabend = slabvalueend;
    schemecode = _schemecode;
    fromdate = _slabstart;
    endate = _slabend;

Below is my button click method code

void clicked()
     Args args = new Args();
    RNI_Scheme2 schemeclass = new RNI_Scheme2();

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 225,672 Super User on at
    RE: wrong type of argument for conversion function

    Using valueStr() is wrong. If you use right methods such as dateValue(), you don't need conversion to text and back to the right type.

    For example, use rni_fromdate.dateValue() instead of any2date(rni_fromdate.valueStr()), text() for string fields, selection() for enum fields and so on.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,417 on at
    RE: wrong type of argument for conversion function

    Hi Syed,

    I believe these two parameters are causing the issue for you - any2date(rni_fromdate.valueStr()) and any2date(rni_enddate.valueStr()).

    Assuming that the form controls are date controls, you can use the dateValue method instead


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 . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,420 Super User

Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans