SETRANGE function on the page

eze
Member Posts: 3
Hi, guys, I have a problem with SETRANGE function usage on a page. I have added CurrentJobNo variable to Job Card page. It should work this way: when I choose a different CurrentJobNo(validate this field), Job Card page should be filtered to only show those Jobs that have Job No. equal to CurrentJobNo.
So the code looks like this:
CurrentJobNo - OnValidate()
SETRANGE("Job No.",CurrentJobNo);
MESSAGE(CurrentJobNo);
MESSAGE("Job No.");
I do not understand why it doesn't work. As you can see I have two messages for testing. So the first message shows the correct value(example J0005) that I want to filter on, but the second message shows the old value. Why does SETRANGE do not filter Job No. to this new value??
So the code looks like this:
CurrentJobNo - OnValidate()
SETRANGE("Job No.",CurrentJobNo);
MESSAGE(CurrentJobNo);
MESSAGE("Job No.");
I do not understand why it doesn't work. As you can see I have two messages for testing. So the first message shows the correct value(example J0005) that I want to filter on, but the second message shows the old value. Why does SETRANGE do not filter Job No. to this new value??
0
Best Answers
-
Does it really not work?
Your messages will not work for sure. SETRANGE only sets the filter and does not alter field values.
But the filter should apply. If you refresh the page, you should get the filtered record; or the page is forcefully closed, if there is no record in the filter. So, you should make sure, the filtered record exists, first. Then, in order to not have to refresh the page manually, call CurrPage.UPDATE.5 -
Hi,
I could get the page filtered. Follow the below steps:
1. I have defined a new variable of code datatype and in On validate of CurrentJobNo which is your new field, assign CurrentJobNo to JobNo variable
2. Setrange between your no field of job table and the JobNo variable which is assigned value in previous step, JobTable is a variable of record datatype i.e. table 167
3. JobListPage is a variable of page datatype ie. Page 89
PAGE.RUNMODAL(89,JobTable);
4. Run your job list page
Code as below:
CurrentJobNo - OnValidate()
JobNo:=CurrentJobNo;
JobTable.SETRANGE("No.",JobNo);
JobListPage.SETRECORD(JobTable);
PAGE.RUNMODAL(89,JobTable);5 -
Your code should be:
CurrentJobNo - OnValidate()
SETRANGE("Job No.",CurrentJobNo);
MESSAGE(CurrentJobNo);
CURRPAGE.UPDATE(FALSE);
and message should be in OaAfterGetCurrRecord() trigger (if you need it):
MESSAGE("Job No.");5 -
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!5
Answers
-
Does it really not work?
Your messages will not work for sure. SETRANGE only sets the filter and does not alter field values.
But the filter should apply. If you refresh the page, you should get the filtered record; or the page is forcefully closed, if there is no record in the filter. So, you should make sure, the filtered record exists, first. Then, in order to not have to refresh the page manually, call CurrPage.UPDATE.5 -
Hi,
I could get the page filtered. Follow the below steps:
1. I have defined a new variable of code datatype and in On validate of CurrentJobNo which is your new field, assign CurrentJobNo to JobNo variable
2. Setrange between your no field of job table and the JobNo variable which is assigned value in previous step, JobTable is a variable of record datatype i.e. table 167
3. JobListPage is a variable of page datatype ie. Page 89
PAGE.RUNMODAL(89,JobTable);
4. Run your job list page
Code as below:
CurrentJobNo - OnValidate()
JobNo:=CurrentJobNo;
JobTable.SETRANGE("No.",JobNo);
JobListPage.SETRECORD(JobTable);
PAGE.RUNMODAL(89,JobTable);5 -
Your code should be:
CurrentJobNo - OnValidate()
SETRANGE("Job No.",CurrentJobNo);
MESSAGE(CurrentJobNo);
CURRPAGE.UPDATE(FALSE);
and message should be in OaAfterGetCurrRecord() trigger (if you need it):
MESSAGE("Job No.");5 -
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions