I have three different fields in Sales Header Table
1. Location 1
2. Location 2
3. Location 3
I had attched Location code on each user on user setup table.
My client want that when any user open sales order/sales invoice form he can view only those orders or invoices in which
(Location = UserSetup.Location) OR (Location 1 = UserSetup.Location)
OR (Location 2 = UserSetup.Location) OR (Location 3 = UserSetup.Location)
How it will possible please let me know if any body knows
Thanks in advance.
VARUN GUPTA
0
Comments
In your case you will have to loop through all of your records and mark the ones that match your filtering criteria. Then set a MARKEDONLY filter so that you only see those records. The other options is almost the same, but instead of marking them you insert them into a temporary table and use that temp table to display the data.
[Edit] A better solution would be a table that lists the allowed locations by user id instead of having Location 1, Location 2, and Location 3. Then you could just set a filter on one field based on the data found in that table.
My Blog - nav.education
sorry, my suggestion doesn't work, use the suggestions that the others gave you.
It was too early and haven't started on my second pot of coffee yet... 8)
Regards,
Willy
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
If you need to preserve MARKs, you might try another approach. Use the form's OnFindRecord and OnNextRecord triggers to filter your record set like this: Note: this was only a quick exercise. It is not tested extensively. In fact, you probably needed to do the search with a local record in order to return the correct data in Rec at all times.
Replace the code of the FilterOk function to match your need (and the SourceTable property of course).
The code works with a card as well as with a list.
EDIT: There was an error in the code which led to an endless loop. Replaced FIND(Which) by FIND(FORMAT(Which)) in all sections of the CASE statement.
If 1 user only assigned 1 Location Code, then you could create a form that filtered for 1 Location Code only, and assigned that to the user.
Sales Header.
Andwian
bcoz i am confuess with 3 location concept.
usersetup.RESET;
usersetup.SETRANGE(usersetup."User ID",USERID);
IF usersetup.FINDFIRST THEN
REPEAT
SalesHeader.RESET;
SalesHeader.SETRANGE(SalesHeader."Location Code",usersetup.Location);
IF SalesHeader.FINDFIRST THEN
REPEAT
SalesHeader.MARK(TRUE)
UNTIL SalesHeader.NEXT=0;
UNTIL usersetup.NEXT=0;
SalesHeader.MARKEDONLY(TRUE);
COPYFILTERS(SalesHeader);