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??
0
Answers
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.
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);
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.");
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!