Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Boolean Check

Posted on by Microsoft Employee


IF (TaxFilter NOT True) or (TaxFilter NOT False) then begin
SalesInvoiceHeader.SETCURRENTLEY(SalesInvoiceHeader."No.");
IF SalesInvoiceHeader.GET("Job WIP G/L Entry"."Document No.") THEN;
IF TaxFilter <> SalesInvoiceHeader."Tax Liable" THEN
CurrReport.SKIP;
END;

WHAT IS WRONG WITH THIS?  

*This post is locked for comments

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Boolean Check

    Your logic works but as Jose mentioned instead of retrieving it apply the filter in the OnPreDataItem trigger of Sales Invoice Header dataitem

    SETRANGE("Tax Liable",TaxFilter);

  • Suggested answer
    jcastro Profile Picture
    jcastro 2,245 on at
    RE: Boolean Check

    In case that the Tax Liable field of the SalesInvoiceHeader is a boolean, you could do as follows in the onpredataitem of the report.

    Tax Liable is boolean

    SalesInvoiceHeader.SETRANGE("Tax Liable",TaxFilter);

    In case that Tax Liable is option

    IF TaxFilter THEN

     "SalesInvoiceHeader".SETRANGE("Tax Liable",SalesInvoiceHeader."Tax Liable"::Yes)

    ELSE

     "SalesInvoiceHeader".SETRANGE("Tax Liable",SalesInvoiceHeader."Tax Liable"::No);

    You should consider filtering out the records that you do not want to work with (the ones you wanna skip) instead of skipping them. Not retrieving them is always more efficient than reading them and doing nothing with them after :-)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Boolean Check

    Ok I got that part; so I will have a request form variable i.e., taxfilter and if taxfilter is true then I only want to get job records where the sales invoice tax liable field is true.  The same goes for false. I would put in the Sales Invoice Header after record; if tax liable<> sales invoice header, currReport.skip  Make sense?

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Boolean Check

    Since Tax filter is a boolean,  it could be either true or false so you don't need to check if it is true or false, as Mohana mentioned the correct way to check that is

    IF (TaxFilter) or (NOT TaxFilter) -- But you need to check this.

  • Suggested answer
    jcastro Profile Picture
    jcastro 2,245 on at
    RE: Boolean Check

    If both fields have the same datatype you should be able to compare them against each other without an issue. If the "Tax Liable" field is an "Option" field, you will have to create something like this:

    boolTaxLiable (boolean variable)

    boolTaxLiable := SalesInvoiceHeader."Tax Liable"::"Yes";

    //IF TaxFilter <> SalesInvoiceHeader."Tax Liable" THEN - COMMENTED

    IF TaxFilter <> boolTaaxLiable THEN

    [...]

    If this does not work could you ellaborate a bit further?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Boolean Check

    I am trying to put filter on the job cost by department report.  TaxFilter is a request form field (Boolean)  and it is compared to the Sales Invoice Header. Tax Liable field (Boolean).  I was not sure if a Boolean field can be blank (not selected)?  So I was checking for that occurrence, however in the code and stepping through the debugger, the TaxFilter field is either true or false, and the sales invoice header tax liable field is yes or no.

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Boolean Check

    What are you expecting from this line of code? can you please explain?

    IF (TaxFilter NOT True) or (TaxFilter NOT False) then begin

    Generally IF TaxFilter THEN itself means Taxfilter = TRUE

    IF not TAXFilter THEN means TaxFilter = FALSE

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans