setrange

Horse06
Member Posts: 496
Hi Expert,
I created a report and I want only A, B, C to view it, but it looks like it does not work, how to fix it? Thanks!
IF TempUser = 'Abc' THEN
BEGIN
"Salesperson/Purchaser".SETRANGE(Code, 'A', 'B', 'C') ;
TempAllow := TRUE;
END;
I created a report and I want only A, B, C to view it, but it looks like it does not work, how to fix it? Thanks!
IF TempUser = 'Abc' THEN
BEGIN
"Salesperson/Purchaser".SETRANGE(Code, 'A', 'B', 'C') ;
TempAllow := TRUE;
END;
0
Comments
-
I'm not getting it.
at one point you have 'abc' and another you have 'a','b','c'.
can you explain a bit better?0 -
Thank yoiu Savatage for your quick response! Yes, I want ABC (the person) to view only the records of A, B, C.
But after I add my code, the ABC can not only see the records of A, B, C, but also D, E, F. Please advise! Thank you very much!0 -
So what do you want to happen if it's NOT user ABC? See all?
or it a report that only should show 'a' , 'b', & 'c'?
if so why not just set the DataItemTableView property to only deal with 'a' , 'b', & 'c'?0 -
I cannot do that, otherwise, when DEF login, he cannot see his sales, but only A's part since it is filtered in the tableviwe. We have serveal sales, each can only view his own sales in the report after login. Currentyly we mixed some of A's accounts with some the B's accounts, so when ABC ( to be exact, ABC is A) login and view the report, he can see his own sales (A), but he can also see some of the mixed sales (B, to be exact, it is AB since some of A's sales mixed with some of the B's sales, or AC). Please advise!0
-
ok so you have a bunch of possibilities.
where are you putting your code?
Do you have sales figures in the salesperson/purchaser table?
it confusing.
looks like you are going to need alot of "if statments" for each possibility
and use currreport.skip if it doesn't fit your criteria.0 -
Thank you Savatage! Before we mixed the accounts, it works well. I am suing setfilter instead of setrange. You are right I am using lot of 'if'.
BTY, you mentions the configuration in the sales/purchase table, any adivce? Thank you!0 -
Also when I am using the following code, I have some issues.
IF TempUser = 'A' THEN
BEGIN
"Salesperson/Purchaser".SETFILTER(Code, 'A') ;
TempAllow := TRUE;
END;
IF TempUser = 'A' THEN
BEGIN
"Salesperson/Purchaser".SETFILTER(Code, 'AB') ;
TempAllow := TRUE;
END;
IF TempUser = 'A' THEN
BEGIN
"Salesperson/Purchaser".SETFILTER(Code, 'AC') ;
TempAllow := TRUE;
END;
A can only see the records for AC, but cannot view his own A and AB. Please advise!0 -
Please advise, experts!0
-
Pretty confusing. You are using three IF commands using the same IF TempUser := 'A' ... so it'll filter only on the last one.
Are you trying to filter the records by the Salesperson or by the person who has logged into NAV?0 -
Yes, I am filtering the records by the person who loggin into the NAV. Is there any better way to achieve this. Thank you!0
-
Ok, now we are getting somewhere. In the report, what's the criteria (filter) you want to use for a user to view some records but not others? In other words, for your DataItems in your report, is there a field or fields we can filter on to get the desired result?0
-
It is the item sales report with two tables (salesperson/Purchaser and Item Variant). I modified the original report, where each salesperson can only view his own sales after login. We have some big customers whom several sales share with, and so we created some new salespersons which are combined with each other, but it makes it difficult for each sales to view his individual mixed accounts sales. Currently we use the salesperson as the filter field. Could you advise?
Thank you!0 -
Oh god, not even basic concepts are understood.
Read the help on filters, on how to combine filters and which operators to use.
Also read up on setfilter and setrange in the help.
Anyway, your filter for your salespersons should be either combined or otherwise split (show own sales first and communist sales second, possible when its a report, not in a form/page without additonal programming)
For salesperson A who has worked with salesperson B and C you either filter once with the following string
A|AB|AC (equals to A or AB or AC)
B|AB|BC for salesperson B
Every time you use setrange/setfilter on a records field, the previous filter of that field is overwritten.0 -
Thank you! It is working now.0
-
Thanks Sog, you were reading my mind on this one!0
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