Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

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

ep_5F00_form.png

ep_5F00_form2.png

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;
    
    this.insert_header();
    this.insert_line();
}

Below is my button click method code

void clicked()
{
     Args args = new Args();
    RNI_Scheme2 schemeclass = new RNI_Scheme2();
     schemeclass.parmmethod(RNI_Brand.valueStr(),RNI_Type.valueStr(),RNI_Product.valueStr(),
    rni_percentage.value(),any2date(rni_fromdate.valueStr()),any2date(rni_enddate.valueStr()),
    rni_schemecode.valueStr(),
    rni_slabstart.value(),rni_slabend.value());
    //super();
}

  • 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

    rni_fromdate.dateValue()
    rni_enddate.dateValue()

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... 288,420 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans