Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Checkbox not working with x++ code

(0) ShareShare
ReportReport
Posted on by 1,479

I have created check box named " show line with scan serial id " in the item arrival forms " line's "  overview header section , i my execute query i have written code so if i click my check box the item with  serial no  scan should appar in grid if i untik check box the grid should be as it is, my code is given below can any one help me out what is wrong with my code.

public void executeQuery()
{
    QueryBuildDataSource   Qbds;

    Qbds = this.query().dataSourceTable(tableNum(WMSJournalTrans));
    Qbds.clearRanges();

    Qbds.addRange(fieldNum(WMSJournalTrans, InventSerialId)).value(queryValue("Scan"));

    super();

}
 

7750.Checkbox.PNG

  • Verified answer
    Martin Dráb Profile Picture
    231,777 Most Valuable Professional on at
    RE: Checkbox not working with x++ code

    Note that your code still contains Qbds variable, which isn't used for anything, therefore it should be deleted. Also note that names of variables should start with lowercase (qbds instead of Qbds).

  • Dineshkarlekar Profile Picture
    1,479 on at
    RE: Checkbox not working with x++ code

    hi martin , your codes is also working ,I am getting desired output 

    thanks for help

    public void executeQuery()
    {
        QueryBuildDataSource   Qbds;
       QueryBuildRange serialIdRange;
    
      Qbds = this.query().dataSourceTable(tableNum(WMSJournalTrans));
    
             serialIdRange =  SysQuery::findOrCreateRange(this.queryBuildDataSource(),
        fieldNum(WMSJournalTrans, InventSerialId));
        serialIdRange.value(checkbox.checked() ? queryValue("Scan") : SysQuery::valueUnlimited());
     
    
        super();
    
    }

    pastedimage1664271020041v1.png

    Checkbox3.PNG

  • Dineshkarlekar Profile Picture
    1,479 on at
    RE: Checkbox not working with x++ code

    thanks for help martin , i have used these two method and getting desired output, i will try to do with the code you provided as well.

    but do i have to use modified method every time ?

    public void executeQuery()
    {
        QueryBuildDataSource   Qbds;
    
        Qbds = this.query().dataSourceTable(tableNum(WMSJournalTrans));
    
     if(checkbox.checked() == NoYes::yes)
        {
            Qbds.addRange(fieldNum(WMSJournalTrans, InventSerialId)).value(queryValue("Scan"));
        }
        else
        {
            qbds.clearRanges();
        }
    
        super();
    
    }

    public boolean modified()
    {
        boolean ret;
    
        ret = super();
       if(ret)
        {
       wmsJournalTrans_ds.executeQuery();
        }
        return ret;
    }

  • Verified answer
    Martin Dráb Profile Picture
    231,777 Most Valuable Professional on at
    RE: Checkbox not working with x++ code

    You're missing an important step in debugging. If you don't get the expected result, look at what query was generated by your code.

    Regarding my code, please add () after valueUnlimited, because it should be a method call. I don't have compiler when writing code here in the forum. :) I'll update the code above.

  • Dineshkarlekar Profile Picture
    1,479 on at
    RE: Checkbox not working with x++ code

    hi martin , i have used the code but getting error . can you plz tell where i am getting wrong.

    public void executeQuery()
    {
        QueryBuildDataSource   Qbds;
        QueryBuildRange serialIdRange;
    
        Qbds = this.query().dataSourceTable(tableNum(WMSJournalTrans));
        Qbds.clearRanges();
    
     /*   Qbds.addRange(fieldNum(WMSJournalTrans, InventSerialId)).value(queryValue("Scan"));*/
        serialIdRange =  SysQuery::findOrCreateRange(this.queryBuildDataSource(), 
        fieldNum(WMSJournalTrans, InventSerialId));
        serialIdRange.value(checkbox.checked() ? queryValue("Scan") : SysQuery::valueUnlimited);
        super();
    
    }

    1643.Screenshot-_2800_5_2900_.png

  • Dineshkarlekar Profile Picture
    1,479 on at
    RE: Checkbox not working with x++ code

    hi girish , thanks for reply ,  If(checkbox.checked()) is also not working , i am not getting deaired output.

  • Dineshkarlekar Profile Picture
    1,479 on at
    RE: Checkbox not working with x++ code

    hi komi , thanks for reply

    i tried your steps but not getting the desired output

  • Dineshkarlekar Profile Picture
    1,479 on at
    RE: Checkbox not working with x++ code

    hi andre ,thanks for reply 

    i have two methods but i am not getting desired output can you please explain.

    public void executeQuery()
    {
        QueryBuildDataSource   Qbds;
    
        Qbds = this.query().dataSourceTable(tableNum(WMSJournalTrans));
        Qbds.clearRanges();
    
        Qbds.addRange(fieldNum(WMSJournalTrans, InventSerialId)).value(queryValue("Scan"));
       
        
        super();
    
    }
    
    

    public boolean modified()
    {
        boolean ret;
    
        ret = super();
        if(ret)
        {
       wmsJournalTrans_ds.executeQuery();
        }
        return ret;
    }

  • Verified answer
    Martin Dráb Profile Picture
    231,777 Most Valuable Professional on at
    RE: Checkbox not working with x++ code

    Yes, I just modified your code. I didn't meant moving it to another method.

  • Dineshkarlekar Profile Picture
    1,479 on at
    RE: Checkbox not working with x++ code

    hi martin , thanks for reply , you want me to write this code in my execute query method.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,907 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,777 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans