web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

wrong type of argument for conversion function

(0) ShareShare
ReportReport
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();
}

I have the same question (0)
  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 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()

  • Verified answer
    Martin Dráb Profile Picture
    236,570 Most Valuable Professional 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.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,771

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 806 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 542 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans