Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, November 24, 2024 
 
Total Control Lookups  
Description:  In this article Stephen Redmond shares another extract from the 3rd edition of his SalesLogix development book, DevLogix. This article covers programmatic use of SalesLogix Lookups, to gain total control over using them in your SalesLogix customizations.

Category:  SalesLogix ActiveX Controls
Author:  Stephen Redmond
Submitted:  10/27/2005
   
Stats: 
Article has been read 28198 times

Rating: - 5.0 out of 5 by 5 users
 

fiogf49gjkf0d
Total Control Lookups

In this article Stephen Redmond shares another extract from the 3rd edition of his SalesLogix development book, DevLogix. This article covers programmatic use of SalesLogix Lookups, to gain total control over using them in your SalesLogix customizations.


In the beginning…

When I first started developing with SalesLogix, I found that lookups were a great tool in my arsenal. It was so easy to add a lookup to a form, set some properties and away you go.

If you wanted to call a lookup from code, however, it was not so easy. What you needed to do was create a dummy form, when it loads then pop the lookup and get the result (into a global variable), and then call CurrentViewCancelShow to close the dummy form before it appeared. A little bit “hacky” to say the least.

When SalesLogix 2000 for Support came along, a couple of new commands – ExecLookupByName and ExecLookupByNameEx – were added, but these only worked in the support client.


And now…

We now have a new command that we can call to open any lookup and return the ID and text of the result. This function is part of the Application.BasicFunctions class.

LookupItemWithConditionByID (
                                 LookUpName, 
                                 RestrictAlways, 
                                 RestrictField, 
                                 RestrictValue, 
                                 RestrictOp, 
                                 InitialText )

This is a powerful function because you have full control over the variables of the lookup such as the Restrict values, etc.

LookUpName: This is the name of the lookup in Table:PrimaryField format.

RestrictAlways: When you set this to true, it always restricts the lookup based on the subsequent properties. If False, you can search on all values.

RestrictField: This is the field that you wish to place a restriction on (e.g. City = Chicago or State = TX, etc.)

RestrictValue: This is the value to compare against the Restrict Field.

RestrictOp: This is the operation to use as the comparison (e.g. =, >, etc.)

InitialText: This is the initial text to display in the lookup.

    Dim LookUp
    Dim LookUpName, RestrictAlways, RestrictField
    Dim RestrictValue, RestrictOp, InitialText

    LookUpName = "Account:Account"
    RestrictAlways = True
    RestrictField = "ACCOUNT:TYPE"
    RestrictValue = "Customer"
    RestrictOp = "="
    InitialText = "Ab"


    Dim AB
    Set AB = Application.BasicFunctions
    Set LookUp = AB.LookupItemWithConditionByID _
                    (LookUpName, RestrictAlways, RestrictField, _
                     RestrictValue, RestrictOp, InitialText)

    MsgBox LookUp.ID, 0, Lookup.DisplayName


The object that is returned by the function is a Link object that has two Properties – ID and DisplayName. ID will return the ID Field of the selected record in the Lookup. DisplayName will return the value of the Name Field of the lookup (defined when you set up the lookup).



 

About the Author

  Stephen Redmond
(SalesLogix Business Partner)
Capricorn Ventis Ltd.

fiogf49gjkf0d
Author of the excellent DevLogix - A Guide to SalesLogix Development (now in 5th edition).


View online profile for Stephen Redmond
 

[ back to top] [ send to a friend]  

Rate This Article you must log-in to rate articles. [login here] 
 
Please log in to rate article.
 

Comments & Discussion you must log-in to add comments. [login here] 
 
Author Article Comments and Discussion
Ted Sturr



Re: Total Control Lookups
Posted: 10/27/2005 5:49:14 PM
fiogf49gjkf0d
Is DevLogix 3rd Edition now available? Ryan's link still references the 2nd Edition. For training purposes I thought that the 2nd Edition was good to get internal staff up to speed - but thought it needed more ActiveX and less legacy - sounds like this is what the 3rd Edition offers. Looking forward to looking at it.

Ted
 
Ryan Farley

slxdeveloper.com Site Administrator
slxdeveloper.com Forum Top 10 Poster!

Re: Total Control Lookups
Posted: 10/27/2005 5:50:47 PM
fiogf49gjkf0d
I don't believe the 3rd edition is available yet, although I do believe it is coming soon.

I'm sure Stephen will chime in and let us know when to expect it.

-Ryan
 
Serg Zhidelyov



Re: Total Control Lookups
Posted: 10/28/2005 4:08:30 PM
fiogf49gjkf0d
Thanks Stephen.
This is a little trick for lookups on localization DB (non cp1252).
For example, need lookup for FieldA.
In Edit Lookup form:
- Search field: FieldA_UC (double field with UpperCase)
- ID field: FieldID
- Name field: FieldA
 
Serg Zhidelyov



Re: Total Control Lookups
Posted: 10/28/2005 5:04:08 PM
fiogf49gjkf0d
Next trick (extension for this article):
Need use more request (where Account.Type='Customer' and Account.Status='Active'):
LookUpName = "Account:Account"
RestrictAlways = True
RestrictField = "ACCOUNT:TYPE"
RestrictValue = "'Customer' AND STATUS="
RestrictOp = "Active"
or
RestrictValue = "'Customer' AND STATUS='Active' AND '1'="
RestrictOp = "1"
 
Stephen Redmond



Re: Total Control Lookups
Posted: 10/28/2005 7:12:13 PM
fiogf49gjkf0d
Ted,

DevLogix III has just been released - www.cafepress.com/DevLogixShop

It is entirely based on the new 6.x technology. If anyone wants the Legacy stuff, there is a legacy book available in the shop.

Stephen
 
Ted Sturr



Re: Total Control Lookups
Posted: 10/31/2005 3:39:18 PM
fiogf49gjkf0d
How do you handle the cancel situation? Right now I am getting an error that the Object does not exist when I try getting the Lookup.ID. I have tried checking IsObject(Label) - returns True., IsEmpty(Label) - returns False and even IsNull(Label) and it returns False.

If I am not able to trap this condition than when I try to access the field I get an Error message that the Object Label is required.

Any ideas?
 
Ryan Farley

slxdeveloper.com Site Administrator
slxdeveloper.com Forum Top 10 Poster!

Re: Total Control Lookups
Posted: 10/31/2005 3:45:53 PM
fiogf49gjkf0d
Ted,

Maybe it would work to try:

If Not Lookup Is Nothing Then
'...
End If

or something? Maybe even checking to see if Lookup.ID exists would work?

Worse case, you could always preceed everything with a:
On Error Resume Next

-Ryan
 
Ted Sturr



Re: Total Control Lookups
Posted: 10/31/2005 3:59:04 PM
fiogf49gjkf0d
Thanks Ryan -
If Not Lookup Is Nothing Then
'...
End If

did the trick.

By the way - off comment question/suggestion - is it possbile to put a copy of the [add comment] button on the bottom of the form as well so you do not have to scroll up? I know, nothing major just occured to me when I wanted to reply to your message.

Ted
 
Ryan Farley

slxdeveloper.com Site Administrator
slxdeveloper.com Forum Top 10 Poster!

Re: Total Control Lookups
Posted: 10/31/2005 5:02:23 PM
fiogf49gjkf0d
Ted,

You know, I've thought that many times. I do plan on doing that, but we'll see...

Thanks,
-Ryan
 
Stephen Redmond



Re: Total Control Lookups
Posted: 10/31/2005 6:16:23 PM
fiogf49gjkf0d
Does TypeName work for you? It should return "Link" if a valid object is returned.


Stephen
 
Dipak Salve
 

Re: Total Control Lookups
Posted: 10/31/2007 8:31:10 AM
fiogf49gjkf0d
i have query that its lookup applicable for existing table SalesLogix
because i am creating an table EmpTable and i want to attach fields of this table for lookup but look does not shows any data
Please help me,

Thanking You in Advance,
 
Irfan Saeed



Re: Total Control Lookups
Posted: 6/26/2008 8:55:23 AM
fiogf49gjkf0d
Serg Zhidelyov,

I tired your trick but don't know why doesn't work.. but tried following trick in 7.0 and 7.2.2 and works perfect.

Lookup.LookupRestrictField = "TYPE = 'Customer' and LOCATION"
Lookup.LookupRestrictValue = "US"
Lookup.LookupRestrictOp = "="

Irfan
 
Serg Zhidelyov



Re: Total Control Lookups
Posted: 6/28/2008 3:13:09 PM
fiogf49gjkf0d
To Irfan.

Sorry, Please try:

Lookup.LookupRestrictField = "TYPE'"
Lookup.LookupRestrictOp = "='Customer' and LOCATION="
Lookup.LookupRestrictValue = "US"
 
Irfan Saeed



Re: Total Control Lookups
Posted: 7/8/2008 5:18:53 AM
fiogf49gjkf0d
Thanks Serg Zhidelyov,

Its actually almost same.

I checked with SQL Trace and it like LookupRestrictField & LookupRestrictOp & "'" & LookupRestrictValue & "'"

ideally you can put anything in there properties to make perfect where clause.

Thanks
Irfan
 
Irfan Saeed



Re: Total Control Lookups
Posted: 7/8/2008 5:19:07 AM
fiogf49gjkf0d
Thanks Serg Zhidelyov,

Its actually almost same.

I checked with SQL Trace and it like LookupRestrictField & LookupRestrictOp & "'" & LookupRestrictValue & "'"

ideally you can put anything in there properties to make perfect where clause.

Thanks
Irfan
 
 

       Visit the slxdeveloper.com Community Forums!
Not finding the information you need here? Try the forums! Get help from others in the community, share your expertise, get what you need from the slxdeveloper.com community. Go to the forums...
 



 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/24/2024 9:21:37 AM