I want to restrict transfer To and From location as details mentioned below
Have a glimpse of the form given below I have 100 locations. now when initiating a transfer order I want to give permission to users so that user can enter only one permitted location at transfer from location...(may be through security filter)
Now I have created another table where I can specify locations against each user. So that at Transfer To location user can only enter the locations that are specified onto the table against their user id
like if my login user id is "production" ,then I can only enter transfer to locations among that are specified on that table, against the Production User id
I can pick up current user id but compairing the user id with the said table and pick locations that are fixed against the user id ....i cant manage the coding....plz help me out
Answers
Why don't you Responsibility Center for this.
if you user Responsibility Center it will help you out from this issue.
Isn't I was asking, but you can have for one user various records.
You can do something like this
Function CheckLocationUser(User, Location)
MyLocations.RESET;
MyLocations.SETRANGE(User ID,User);
MyLocations.SETRANGE(Location Code,Location);
IF (MyLocations.FINDFIRST()) THEN
EXIT(TRUE)
ELSE
EXIT(FALSE)
Then on the transfer from and to validate.
IF NOT (CheckLocationUser(USERID, Transfer-from Code)) THEN
ERROR('Your mesage');
I have created a table named MyLocation, consists two fields location and user id as follows
Now as per your solution I have implemented the code but getting errors regarding defining variables …
I have defined user id and location variable under the function checkloacion
and defined global variables myLocation=record--tablename
user--recrd-user
location--record -location
Have defined the function as well still error..
is there something I miss during declaration of variables
You need to add 2 parameters to CheckLocationUser: "User" (type code[50]) and "Location" (type code [10]), although personally, I'd use different names, because "User" and "Location" are table names as well, so it might be confusing later on.
my requirement is there is a table consists user ids and location(as you saw in screenshot) then when I login and try to enter a location code in transfer to location then system will check if current user id is assigned with that location in that table if the location is not defined for the user then it will show error message else will permit...
is it serve the requirement?
Yes, that will do what you want. Although you can simplify your code in CheckLocationUser function: You don't need RESET if "MyLocations" is declared as local variable, because it gets cleared automatically as soon as the function finishes executing
FINDFIRST has a return value (TRUE if found, FALSE if not), so we can just put that into EXIT.
Alternatively, if your MyLocations table's Primary Key consists only of "User ID" and "Location Code", your entire function code can be simply:
If I understand correctly, you also have a date filter (from when to when the user can use a specific location). If so, then you need to use the first example, and add additional filters as well as a new parameter (must not forget it when calling the function! I suggest using "Posting Date" or "Document Date", depending on your needs):
my client comp dont want from-to date restriction so i went with user and location restriction only.
I have specified all as you said....
still getting the error shown in attached screenshot.
user :=(current logged in user) and Transfer-to Code := (is the location code the user entered)
i am trying to call the function so that it can check if current user and given location is defined in in mylocation table or not if not it will show error msg(example if india japa and france are 3 locations,and user is James.if in mylocation table James is assigned with only india and japan) so if James enters france at transfer-to code then he will get the error msg.
I am also attache the transfer header table in txt format and mylocations table also in txt format.
plz plz help
wd u plz share ur mail id...my one anosua@outlook.com
Go to the function CheckLocationUser and open its local variables (CTRL+L on NAV 2016+). Then under parameters tab define MyUserID (code [50]) and MyLocationCode (code [20]).
It should look something like this:
And then make sure MyUserID and MyLocationCode do NOT exist as global variables as well, because then it will NOT work.
Another table for example,warehouse employee does the same,sending you the screenshots....but instead of using Mylocations table,i can also use the warehouse employee table bit the problem is that it has common names of variable like user,location.....it may clash as you said earlier?
but warehouse employee table with similar
fields allowing to assign multiple locations as shown below
Your code just exits. The last two lines of the function code need to be replaced with: That will make that part work
The other thing, why you're not able to insert more records is because your primary key (the fields defining each record as unique) only consists of field "User ID". This means that when you try to insert another location for the user, NAV checks and sees that there is already a record in the table with the same unique "identifier", because Location Code is NOT part of the primary key ("identifier").
To add Location Code to the Primary Key, you should first delete all the records from the table, then go back to the designer, design the table, then click on the View->Keys. This will open a window with all the keys defined on the table. The first key in the list is ALWAYS the primary key
Please read up on the keys, what they do, how to define and use them. You need to add field "Location Code" to the first (primary) key.
And finally, as you've noticed yourself, there's already a Warehouse Employee table. If none of the other functions/modules you use makes use of that table, you can use it for your own needs. In your code you then need to replace the MyLocations table with Warehouse Employee table (change variable name, subtype and then rename it in the code as well).
If you do decide to go with this, your final CheckLocationUser code should look like: Here WarehouseEmployee is a record type variable with subtype "Warehouse Employee". See my first post on using GET instead of filtering first.
1)If location left blank against any user in mylocations table then, the user can have access to any location.like if left blank then skips the error message and can enter any location he want to
2)In transfer order form,if user A is given access to 11 and 22 location ,then he can only ship to 11 and 22 location,cannot ship and receive both to 11 and 22 location
3)the above mentioned thing ,i suppose can be done by specifying the same function calling in Transfer order post receipt codeunit (under Onrun).So that if i assign recieving locationg same as transfer location for any user then he can only recieve for those location,else will get error.
if he tries to recieve the order then the function will check if transfer to code and reciving location code is same or not if not then will show the error message.
is it ok?
Suppose the user 0027 is assigned with location "SUPREME". then suppose the user tries to receive a transfer order that has transfer to location "PROD" then he get the error(same error as we done before...you r not assigned etc."
if "transfer to location" <>"receiving location" then user will get error after clicking "OK" of "receive" Boolean
if transfer to location and receiving location(assigned to user in the table) is same then he will not get error.
for that should i copy the same code on transfer order post reciept table or anything alse?plz advice
thanks a lot
So the user can receive any released transfer order on behalf of the to location code .
If I put the function calling in transfer to location then the user cannot ship to that location which he is not assigned to. But which is required that he can ship to any location but cannot receive the shipped order .That’s why I want to put the code when post receiveok is clicked.