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

How to clear the date field with checkbox when unchecked ?

(0) ShareShare
ReportReport
Posted on by

Hi Expert

I have some problem to set date field be empty.

This's my code,

If(myCheckBox == False)

{

  SalesParam.TransDate.valueStr() == datenull();

}

Or

If(myCheckBox == False)

{

  SalesParam.TransDate = datenull();

}

I have try this code but still error,?

Can someone share. What should i do ?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to set date field empty with checkbox ?

    Hi Agung.Pranyoto,

        Please tell me where your writing this code? means in table level or anywhere in form?

        If your writing this code in table level modified field, you should mention the case field which you are modified.

      

    case fieldNum(Table1, QtyOLabelRecievedByunit1FromUnit6Manual):
    case fieldNum(Table1, TotalLabels):
                   
    this.QtyOLabelRecievedByunit1FromUnit6 = this.QtyOLabelRecievedByunit1FromUnit6Manual + this.TotalLabels;


    Thanks

    Suresh

  • Community Member Profile Picture
    on at
    RE: How to set date field empty with checkbox ?

    Hi Suresh potlakayala,

    I writing code at Overide method modified in checkbox.

    When I writing this code,

    - SalesParmTable_Transdate.valueStr() == dateNull(); //Error message : Syntax Error

    - SalesParmTable_Transdate = dateNull(); //Error message : Operand types are not compatible with the operator.

    this's my full code in modified method

    public boolean modified()

    {

       boolean ret;

       ret = super();

       if(OpenDate.value() == boolean::true)

       {

           info("Mod True");

       }

       else

       {

           SalesParmTable_Transdate = dateNull();

           info("Mod False");

       }

       return ret;

    }

    can you give me a solution for my problem.

    Thanks

    Agung

  • Mea_ Profile Picture
    60,284 on at
    RE: How to set date field empty with checkbox ?

    Hi Agung Pranyoto,

    If you want to set value of date control use next:

    SalesParmTable_Transdate.dateValue(dateNull());


    but it's better to set value of data source field directly, because you may have multiple controls using same datasource field:

    SalesParmTable.transDate = dateNull();


  • Community Member Profile Picture
    on at
    RE: How to set date field empty with checkbox ?

    Hii ievgen Miroshnikov,

    I have added this code as below :

    --------------------------------------------------

    public boolean modified()
    {
    boolean ret;

    ret = super();

    if(OpenDate.value() == boolean::false)
    {
    SalesParmTable_Transdate.dateValue(dateNull());
    SalesParmTable_DocumentDate.dateValue(dateNull());
    }
    return ret;
    }

    -------------------------------------------------

    but when I did unheckbox field Invoice date and document date can not be empty.? what's wrong with this code ? 

     5810.sales.jpg

    Thanks,

    Agung

  • Verified answer
    Mea_ Profile Picture
    60,284 on at
    RE: How to set date field empty with checkbox ?

    Don't change controls, change value of table fields they linked to:

    public boolean modified()
    {
        boolean ret = super();

        if (OpenDate.value() == false)
       {
            salesParmTable.Transdate = dateNull();
            salesParmTable.DocumentDate = dateNull();
        }
        return ret;
    }

  • Community Member Profile Picture
    on at
    RE: How to set date field empty with checkbox ?

    Hi ievgen,

    when i did change code, I got error as below :

    7356.sales1.jpg

    Actually, I just want to clear date at this field  (Invoice date & Document date)

    Thanks,

    Agung

  • Mea_ Profile Picture
    60,284 on at
    RE: How to set date field empty with checkbox ?

    You ignored what I proposed and changed code in a different way, now you have a compile error. I already gave you code snippet, so please use it.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to set date field empty with checkbox ?

    Hi,

        set your field property auto declaration = Yes, Mention your form field name instead of "SalesParmTable_Transdate"  

    Thanks

    Suresh

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to set date field empty with checkbox ?

    Hi Agung Pranyoto,

       If you want clear date when you uptick the check box, you better do this coding in form active or field leave method.

    Thanks

    Suresh

  • Community Member Profile Picture
    on at
    RE: How to set date field empty with checkbox ?

    Hi ievgen Miroshnikov,

    Sorry i forgot to change my code, I just followed your code, it's work fine but transdate & documentdate will be empty/clear when I move the pointer to another field? What should i use that method clicked ?

    and what's difference between  SalesParmTable_Transdate and salesParmTable.Transdate ?  

    4251.sales2.jpg 

    Thanks,

    Agung

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

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#1
Community Member Profile Picture

Community Member 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans