Function question

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
JAW
User
Posts: 98

Function question

Post by JAW »

Hello,
I am relatively new to .Net and I need a little assistance with something. I have hard coded something that is working to some extent but I can't get a couple things figured out. Here are my two questions.

1.) The following code is working with one exception. I added CurrentLocation() to the Advanced Options/Auto Update values and use that on the field for the SiteID and that works fine. When a new record is added the field is populated properly. I also use it in multiple dynamic drop down filters and it works fine there as well. The drop downs are filtering based on the CurrentLocation() value. The problem is in the Table Filter it fails. I can not seem to figure out why. I want to filter the records from the table based on this code. The table returns no results when this is used as a filter. If I add a record and this code is in the SiteID Auto Update option the record is added but the table comes back with no results.

public static string CurrentLocation()
{
return Convert.ToString("MYFACILITY");
}

2.) I would like the code to be dynamically drawn from the UserLogin table. Each user is assigned to a specific Facility. When someone logs in I would like the Function to select their Facility from the UserLogin Table dynamically. I can do this very easily in classic ASP and ASPMaker but in .Net I am at a loss. Can anyone point me in the direction to get this to work? I have been googling it for days and have not found a solution that I can make work. What I need is something like this;

If anyone has any suggestions they will be greatly appreciated.

Thanks in advance,
JW


vincenthung
User
Posts: 88

Post by vincenthung »

For question 1:

Enable the option "Debug" in [Tools] -> [Advanced Settings] -> [Debug] to show the SQL which load the records, in order to make sure the SQL is work as expected.

About question 2:
You can add your code to filter the records in "Recordset_Selecting" server event
On the other hand, you can get current user's info from the user table with the function "CurrentUserInfo()"

For example:
var Facility = CurrentUserInfo("<Field>");
ew_AddFilter(ref filter, "<Field> =" + Facility);

Read help file topic: "Server Events and Client Scripts -> Some Global Functions" for more information.


JAW
User
Posts: 98

Post by JAW »

Hello Vincent,
Thanks so much for the reply. That was exactly what I needed and it is working perfectly now. Your suggestion to use Recordset_Selecting caused some errors but I used the code you sent to create the function necessary to filter the records the way I needed. I sincerely appreciate you taking the time to post your suggestion. In the end my solution was;

public static string CurrentLocation()
{
return Convert.ToString(CurrentUserInfo("<Field>"));
}

Then I filter the records in the table based on the above.

Thanks again,
JW


Post Reply