Normal Topic Controlling the Retrieve Spec (Read 825 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Controlling the Retrieve Spec
Aug 25th, 2012 at 2:44am
Print Post Print Post  
Hi all,

Got another one for you.  I want to set certain records off limits for staff.  Here's what I'm trying, but it doesn't seem to be working.

1) In my staff database, I have created a StaffLimitBranch field.

2) I've tried to force the retrieve spec to include whatever is in my customer database retrieve field of DBBranch with the following code on Form Exit

Code
Select All
if @mode() = 2
{
DBBranch = @xlookup(@FN,"Staff Screen!StaffLimitBranch",@userid,"DBBranch")
vButtonOn = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")
}
 



Why isn't this working?
  
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Controlling the Retrieve Spec
Reply #1 - Aug 25th, 2012 at 1:41pm
Print Post Print Post  
It looks like you've got your Key and Ext_Key parameters reversed in the @XLookup command.

The way it reads now, you are asking it to find the literal string "Staff Screen!StaffLimitBranch" in a field named the same as the current @UserID (i.e. someone's name).
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: Controlling the Retrieve Spec
Reply #2 - Aug 25th, 2012 at 8:16pm
Print Post Print Post  
Hi Carl,

Sorry ... I was tired and typed from memory, not cutting and pasting.

Okay, so attempt two ... I created the following (pasted) global code in my customer screen:

Code
Select All
//
IgnoreKey(KEYCODE_F3,0)


===========================================
// Look Up User Restrictions -- BW 2012-08-25
// ===========================================
gStaffLimit = (@Xlookupsourcelist(@FN, @userid, "Staff Screen!StaffRef", "StaffLimitBranch;StaffLimitClt;StaffLimitUser"))
 



I then tried the following on Retrieve Spec Open (which didn't work):

Code
Select All
	if @accessstringarray(gStaffLimit,1) <> ""
	{
		DBBranch = @accessstringarray(gStaffLimit,1)
	}

	if @accessstringarray(gStaffLimit,2) <> ""
	{
		DBCltNo = @accessstringarray(gStaffLimit,2)
	}

	if @accessstringarray(gStaffLimit,3) <> ""
	{
		DBColl# = @accessstringarray(gStaffLimit,3)
	}
 



And then to keep pesky staff from altering those fields, I created a code on element entry (again, didn't work):

Code
Select All
if @accessstringarray(gStaffLimit,3) <> "" then Throwfocus(DBNote0)
 



So, the problem seems to be I can't limit or control what is happening in the Search Screen ... I can populate elements, but I can't restrict navigation or alteration of what I have inserting ... help?
  
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Controlling the Retrieve Spec
Reply #3 - Aug 26th, 2012 at 2:32am
Print Post Print Post  
I'd start by verifying that the lookup is working as expected, by adding a WriteLn command. If it fails to show anything in the slate, start checking that you are using the proper spelling of the LE names. (You want to be using the LE names, not the field names like you would for XResultSetSearch.)

Add a WriteLn like this:
Code
Select All
gStaffLimit = (@Xlookupsourcelist(@FN, @userid, "Staff Screen!StaffRef", "StaffLimitBranch;StaffLimitClt;StaffLimitUser"))
WriteLn(gStaffLimit) 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: Controlling the Retrieve Spec
Reply #4 - Aug 26th, 2012 at 6:06am
Print Post Print Post  
Hi Carl,

The xlookupsourcelist is working fine ... I created a dummy user account, and it's populating the search screen with the limiting data.

The frustrating thing is I can (as the dummy user) just click on the limiting fields and edit the retrieve spec, hit F10, and have wide open access. 

Why won't my code on Element Entry throwfocus like I would like?

(Since I wrote this, I've tried a few things ... ReadOnly, Attribute, etc ... nothing seems to work ...)
  
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Controlling the Retrieve Spec
Reply #5 - Aug 27th, 2012 at 12:29am
Print Post Print Post  
Ohhhh! I've been thinking that you were not able to populate the fields. You meant you couldn't prevent someone from changing it before pressing F10, right?

Quote:
Why won't my code on Element Entry throwfocus like I would like?

That's because the On Element Entry events only work for command buttons in Search mode. The only other events that will work there are:
On Retrieve Spec Open
On Reveal
On Hide
On Form Reveal
On Form Hide
On Draw
Universal Event


You need to use "ReadOnly(LE_Name, 1)" in the [FormName] :: On Retrieve Spec Open event, and then "ReadOnly(LE_Name, 0)" in the [FormName] :: On Form Entry event. This will prevent users from changing the value at the search screen, but allow them to edit the record, assuming that is want you want. If not, then just make the field always read-only.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Acebanner
Full Member
***
Offline



Posts: 123
Location: New York City
Joined: Jan 23rd, 2008
Re: Controlling the Retrieve Spec
Reply #6 - Aug 27th, 2012 at 1:14pm
Print Post Print Post  
BWETTLAUFER wrote on Aug 25th, 2012 at 2:44am:
Hi all,

Got another one for you.  I want to set certain records off limits for staff.  Here's what I'm trying, but it doesn't seem to be working.



Are you trying to prevent alteration of a series of specific records? Records that you specify on an individual basis? I have some programming I use to 'close the books' on production records older than a certain date. But I'm not sure if that's what you're trying to do. In my fix there's a global variable that holds the 'close date' -- I then some programming to check and see if the record being entered falls before or on that date. If it does, a list of protected fields is run through, and they're all set to ReadOnly, and a static text indicating that the record is 'closed' is made visible. Every few months I change the date forward a bit. Also, you can set the programming to not fire if the userid is an admin.

If that would suit your needs, let me know and I can post the programming.
  
Back to top
IP Logged