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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Boolean SetRange doesn't work for Job Queue

(0) ShareShare
ReportReport
Posted on by

Hello Members,

I run into an issue where I have to setup a job queue with the following scenario. 

- I created own table and the field type boolean is not part of the primary keys

- I created a code unit which filters as follows: NEWTABLE.SETRANGE("Boolean FIELD", FALSE) , that the only filter

-  IF NEWTABLE.FIND('-') THEN BEGIN END;

- NOTE: The NEWTABLE includes record with boolean field true and false

- When I run the code unit, it is going through the loop (eg. finding the record)

- BUT when i try the same code unti via Job Queue, its not going through the loop.

Any idea?

*This post is locked for comments

I have the same question (0)
  • sorenk Profile Picture
    on at

    Can you show a little more of your code. I would use a findset instead of a find('-'), but there should be no difference between the execution locally and in the Job Queue.

  • Community Member Profile Picture
    on at

    Here is what I have in code unit.....

    CLEAR(ShipmentImportData);

    ShipmentImportData.SETRANGE("Is Sales Order Updated",FALSE);

    IF ShipmentImportData.FIND('-') THEN BEGIN

     REPEAT

    //updating Sales order table

     UNTIL ShipmentImportData.NEXT = 0;

    END;

    when I run code unit from development environment, it found records and went through the loop and updating the SO but when I run the same code unit via Job Queue, it not finding any records.

    Its strange, Instead of SETRANGE, when I use the following filter: ShipmentImportData.SETFILTER("Is Sales Order Updated",'<>%1',TRUE);it went through the loop and updated the SO.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    It is bit strange but i am not sure why would it behave that way. Try to use RESET function before apply any filters and try again.

  • Suggested answer
    sorenk Profile Picture
    on at

    I would simplify the code a little by writing it as this.

    CLEAR((ShipmentImportData);

    ShipmentImportData.SETRANGE("Is Sales Order Updated",FALSE);

    IF ShipmentImportData.FINDSET THEN

     REPEAT

       //updating Sales order table

     UNTIL ShipmentImportData.NEXT = 0;

    Use FINDSET instead of FIND('+')

    No need for the BEGIN END; unless you have other code not mentioned.

    I would also use RESET instead of CLEAR unless you have a specific reason for using CLEAR.

    Waldo has created a good "How do I" Video on use of NAS that might help you too. I am assuming here that you are running a 3 tier architecture.

    www.youtube.com/watch

    There is no difference between using SETRANGE and SETFILTER to my knowledge out side that they work slightly different. In this example they should provide the same result.

    Let me know if this answer helps you.

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    As suresh said it is bit strange thing to happen. Try the code with

    Reset, FINDFIRST

  • Community Member Profile Picture
    on at

    Thank you very much Suresh. I changed it to reset but didn't work. I know its strange but works.

  • Community Member Profile Picture
    on at

    Thank you very much Soren for the suggestions and video. Yes, I am using 3 tier architecture.

  • mmv Profile Picture
    11,471 on at

    Hi,

    Is your issue resolved?  If not, could you share the screen print of the code?

  • mmv Profile Picture
    11,471 on at

    Hi,

    One more suggestion, after changing the code, did you restart the NAV session and restarted the Job Scheduler?

  • Alchmeist Profile Picture
    10 on at

    Type code in this format-:

    NewTable.reset

    NewTable.setrange(BoolField,False);

    if  NewTable.findset then begin

     repeat

       ..........Write the valid conditions..........  

     until NewTable.next =0;

    end;

    This will help you.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans