setrange

Horse06Horse06 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;

Comments

  • SavatageSavatage Member Posts: 7,142
    I'm not getting it.

    at one point you have 'abc' and another you have 'a','b','c'.

    can you explain a bit better?
  • Horse06Horse06 Member Posts: 496
    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!
  • SavatageSavatage Member Posts: 7,142
    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'?
  • Horse06Horse06 Member Posts: 496
    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!
  • SavatageSavatage Member Posts: 7,142
    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.
  • Horse06Horse06 Member Posts: 496
    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!
  • Horse06Horse06 Member Posts: 496
    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!
  • Horse06Horse06 Member Posts: 496
    Please advise, experts!
  • jspoppjspopp Member Posts: 54
    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?
  • Horse06Horse06 Member Posts: 496
    Yes, I am filtering the records by the person who loggin into the NAV. Is there any better way to achieve this. Thank you!
  • jspoppjspopp Member Posts: 54
    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?
  • Horse06Horse06 Member Posts: 496
    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!
  • SogSog Member Posts: 1,023
    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.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • Horse06Horse06 Member Posts: 496
    Thank you! It is working now. :lol:
  • jspoppjspopp Member Posts: 54
    Thanks Sog, you were reading my mind on this one!
Sign In or Register to comment.