Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, November 27, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Combine Account and Contact Lookup
Corey Harbaugh
Posts: 31
 
Combine Account and Contact LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Jan 07 3:33 PM
fiogf49gjkf0d
I'm creating a new Main View and want the Quick Finder lookup to search both Account and Contact tables for the value entered.

Any ideas?
[Reply][Quote]
Corey Harbaugh
Posts: 31
 
Re: Combine Account and Contact LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Jan 07 4:24 PM
fiogf49gjkf0d
I think I figured out something that will work. I created a custom entity table with columns entityid and entity that will contain account or contact. The custom entity table will be my base table and I'll create global joins to the main Account and Contact table.

If anyone foresees any problems this may cause please speak up!
[Reply][Quote]
Brian Kempe
Posts: 53
 
Re: Combine Account and Contact LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Jan 07 1:04 PM
fiogf49gjkf0d
I created a Search tool for my company that searches both Accounts and Contacts as the entry screen. You can see a screen shot at internetfresno.com/search.bmp If you would like I can paste the code here for you.
Brian
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Combine Account and Contact LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Jan 07 2:35 PM
fiogf49gjkf0d
From the bitmap it looks like you created a MainView. Don't those have to be linked to a base table? Did you create one specifically for the lookup?

Forgive me for asking, but why not just use the Lookup menu items? Why combine the two?

I'd like a rundown of your code if you don't mind. It probably doesn't take much but getting a mainview to behave like that may take a little finesse. I could probably work it all out given time but maybe there's something you do that I don't necessarily think about.
[Reply][Quote]
Brian Kempe
Posts: 53
 
Re: Combine Account and Contact LookupYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Jan 07 3:42 PM
fiogf49gjkf0d
I am basing the dataform on a custom main table with basically nothing in it just to act as anchor, and then querying Contact and Account.
The main reason I built this was so that end users can take a call form a customer and not have to change screens . They could search for name or company and determine whether the client already exists, and use a midstring search to boot. Here is the code behind it. No laughing, Ive only been working with SalesLogix for five monthes :D
Oh. And so you know the search is progressive in that it accumulates search criteria. effectively narrowing the results untill you hit reset.
_____________________________________________________________________________
'Including Script - System:Insert Ticket
'Including Script - System:SLX_Common
'Including Script - System:SLX Contact Account Support

option explicit
dim bk_debug
dim strCNTa
dim strCNTb
dim str_orig_dg1SQL
dim str_orig_dg2SQL
bk_debug=0

Sub AXFormOpen(Sender)
str_orig_dg1SQL=DataGrid1.SQL.Text
str_orig_dg2SQL=DataGrid2.SQL.Text
End Sub

Sub SearchClick(Sender)
call FilterGrid1
call FilterGrid2
checkit.Text=checkit.Text+1
if (strCNTa + strCNTb=2) then
checkit.Text=0
end if
Name.Text=""
Company.Text=""
'City.Text=""
'State.Text=""
'Phone.Text=""
end sub

Sub FilterGrid1
Dim strPart1
Dim strPart2
Dim strPart3
if checkit.Text ="0" then
strPart1=str_orig_dg1SQL
strPart2=" WHERE (A1.ACCOUNT LIKE '%" & Company.Text & "%' ) "
End If
If checkit.Text>0 then
strPart1=DataGrid1.SQL.Text
strPart2=" AND (A1.ACCOUNT LIKE '%" & Company.Text & "%' ) "
Dim cutout
cutout=inStr(1,strPart1,"ORDER BY")
strPart1=Left(strPart1, cutout-1)
End If
strPart3=" AND (A1.MAINPHONE LIKE '%" & Phone.Text & "%' "
'if Phone.Text="" then strPart3= strPart3 & " or A1.MAINPHONE is NULL) " ELSE strPart3= strPart3 & " ) "
strPart3= strPart3 & " or A1.MAINPHONE is NULL ) "
strPart3= strPart3 & "AND (A2.CITY LIKE '%" & City.Text & "%' or A2.CITY is NULL) " &_
"AND (A2.STATE LIKE '%" & State.Text & "%' or A2.STATE is NULL) ORDER BY "
if PHONE.Text<>"" then strPart3= strPart3 & " A1.MAINPHONE desc, "
if STATE.Text<>"" then strPart3= strPart3 & " A2.state desc, "
if CITY.Text<>"" then strPart3= strPart3 & " A2.city desc, "
strPart3= strPart3 & " A1.ACCOUNT , "
if STATE.Text="" then strPart3= strPart3 & " A2.state , "
if CITY.Text="" then strPart3= strPart3 & " A2.city , "
strPart3= strPart3 & " A1.ACCOUNTID "
'msgbox strPart1 & strPart2 & strPart3
DataGrid1.SQL.Text=strPart1 & strPart2 & strPart3
DataGrid1.Refresh
if (DataGrid1.NodesCount <1) then
strCNTa=1
Else
strCNTa=0
End if
'msgbox "maxrowlinecount= " & DataGrid1.NodesCount
end Sub

Sub FilterGrid2
Dim strPart1
Dim strPart2
Dim strPart3
if checkit.Text ="0" then
strPart1=str_orig_dg2SQL
strPart2=" WHERE (A1.LASTNAME LIKE '%" & Name.Text & "%' OR A1.FIRSTNAME LIKE '%" & Name.Text & "%' ) "
End If
If checkit.Text>0 then
strPart1=DataGrid2.SQL.Text
strPart2=" AND (A1.LASTNAME LIKE '%" & Name.Text & "%' OR A1.FIRSTNAME LIKE '%" & Name.Text & "%' ) "
Dim cutout
cutout=inStr(1,strPart1,"ORDER BY")
strPart1=Left(strPart1, cutout-1)
End If
strPart3="AND (A1.ACCOUNT LIKE '%" & Company.Text & "%') " &_
"AND (A1.WORKPHONE LIKE '%" & Phone.Text & "%' "
'if Phone.Text="" then strPart3= strPart3 & " or A1.WORKPHONE is NULL) " ELSE strPart3= strPart3 & " ) "
strPart3= strPart3 & " or A1.WORKPHONE is NULL ) "
strPart3= strPart3 & " AND (A2.CITY LIKE '%" & City.Text & "%' or A2.CITY is NULL) " &_
"AND (A2.STATE LIKE '%" & State.Text & "%' or A2.STATE is NULL) ORDER BY "
if PHONE.Text<>"" then strPart3= strPart3 & " A1.WORKPHONE desc, "
if STATE.Text<>"" then strPart3= strPart3 & " A2.state desc, "
if CITY.Text<>"" then strPart3= strPart3 & " A2.city desc, "
strPart3= strPart3 & " A1.LASTNAME ,A1.FIRSTNAME, A1.ACCOUNT, "
if STATE.Text="" then strPart3= strPart3 & " A2.state , "
if CITY.Text="" then strPart3= strPart3 & " A2.city , "
strPart3= strPart3 & " A1.CONTACTID "

'msgbox strPart1 & strPart2 & strPart3
DataGrid2.SQL.Text=strPart1 & strPart2 & strPart3
DataGrid2.Refresh
if (DataGrid2.NodesCount <1) then
strCNTb=1
Else
strCNTb=0
End if
end Sub

Sub RESETClick(Sender)
checkit.Text="0"
Name.Text=""
Company.Text=""
Phone.Text=""
State.Text=""
City.Text=""
DataGrid1.SQL.Text=str_orig_dg1SQL & " WHERE 1=0"
DataGrid2.SQL.Text=str_orig_dg2SQL & " WHERE 1=0"
DataGrid1.Refresh
DataGrid2.Refresh
End Sub

Sub DataGrid1DblClick(Sender)
Dim sID
Dim BaseTableName
sID=DataGrid1.GetCurrentField("ACCOUNTID")
BaseTableName="ACCOUNT"
Application.MainViews.GetViewForRecord sID, BaseTableName
End Sub

Sub DataGrid2DblClick(Sender)
Dim sID
Dim BaseTableName
sID=DataGrid2.GetCurrentField("CONTACTID")
BaseTableName="CONTACT"
Application.MainViews.GetViewForRecord sID, BaseTableName
End Sub

Sub DataGrid1PopupMenuClick(Sender, Item)

dim strCrntID
if bk_debug >0 then msgbox Item.MenuIndex End If
Select Case Item.MenuIndex
Case 0
NewAccount
Case 1
GotoAccount
Case 2
NewTicket
Case 3
NewOpportunity
Case 4
AccountDetail


End Select
End Sub

sub NewAccount
call AddContactandAccount
End Sub

Sub GotoAccount 'DO NOT CHANGE
Application.MainViews.GetViewForRecord DataGrid1.GetCurrentField("ACCOUNTID"), "ACCOUNT"
End Sub

sub AccountDetail 'DO NOT CHANGE
Application.BasicFunctions.showViewForRecord "ACCOUNT","system:Account Detail", DataGrid1.GetCurrentField("ACCOUNTID")
End Sub

Sub Newticket
Dim objMainView, objAccountDetail
Set objMainView = Application.MainViews.Add("System:Insert New Ticket - Account Service Information", 0, False) 'DNL
objMainView.Caption = Application.Translator.Localize("Insert New Ticket - Account Service Information")
objMainView.Height = 642
objMainView.Width = 875
objMainView.BorderStyle = 3
Set objAccountDetail = objMainView.DetailsView
objAccountDetail.Script.Init "Insert", DataGrid1.GetCurrentField("ACCOUNTID") 'DNL
CallInsertNewTicketView True, objAccountDetail
End Sub
Sub CallInsertNewTicketView(blnAccntService, objAccountDetail)
Dim objMainView2, objDetail
Set objMainView2 = Application.MainViews.Add("System:Insert New Ticket", 2, False) 'DNL
objMainView2.Caption = Application.Translator.Localize("Insert New Ticket")
objMainView2.Height = 642
objMainView2.Width = 875
Set objDetail = objMainView2.DetailsView
objDetail.lveAccount.LookupID = objAccountDetail.lveAccount.LookupID
objDetail.lveAccount.Text = objAccountDetail.lveAccount.Text
objDetail.chkSubmitSearch.Checked = SetSearchDefault()
objMainView2.Show
End Sub

Sub NewOpportunity
Dim objMainViewOp1, objOpDetail, Obj1, Obj2, Obj3, Obj4
Set objMainViewOp1 = Application.MainViews.Add("System:Insert Opportunity", 0, False)
objMainViewOp1.Caption = Application.Translator.Localize("Insert Opportunity")
objMainViewOp1.Height = 642
objMainViewOp1.Width = 875
objMainViewOp1.BorderStyle = 3
Set objOpDetail = objMainViewOp1.DetailsView
objOpDetail.lveAccount.Text=datagrid1.GetCurrentField("Account")
Obj1=datagrid1.GetCurrentField("AccountID")
Obj2=datagrid1.GetCurrentField("A3_DiscountCode")
Obj3=datagrid1.GetCurrentField("A3_CarrierID")
Obj4=datagrid1.GetCurrentField("A3_PrimaryCurr")
OpView True, objOpDetail, Obj1, Obj2, Obj3, Obj4
End Sub
Sub OpView(blnAccntService, objOpDetail,Obj1,Obj2,Obj3, Obj4)
Dim objMainViewOp, objDetail
Set objMainViewOp = Application.MainViews.Add("System:Insert Opportunity", 2, False)
objMainViewOp.Caption = Application.Translator.Localize("Insert Opportunity")
objMainViewOp.Height = 642
objMainViewOp.Width = 875
Set objDetail = objMainViewOp.DetailsView
objDetail.lveAccount.Text = objOpDetail.lveAccount.Text
objDetail.AccountId.Text = Obj1
objDetail.DistCode.Text = Obj2
objDetail.CarrierID.Text = Obj3
objDetail.PrimaryCurr.Text = Obj3
objMainViewOp.Show
End Sub

Sub DataGrid2DblClick(Sender)
Dim sID
Dim BaseTableName
sID=DataGrid2.GetCurrentField("CONTACTID")
BaseTableName="CONTACT"
Application.MainViews.GetViewForRecord sID, BaseTableName
End Sub

Sub DataGrid2PopupMenuClick(Sender, Item)
dim strCrntID
if bk_debug >0 then msgbox Item.MenuIndex End If
Select Case Item.MenuIndex
Case 0
NewContact
Case 1
GotoContact
Case 2
NewContactTicket
Case 3
NewContactOpportunity
Case 4
ContactDetail
End Select
End Sub

Sub NewContact
call AddContactAndAccount
End Sub

Sub GotoContact 'DO NOT CHANGE
Application.MainViews.GetViewForRecord DataGrid2.GetCurrentField("CONTACTID"), "CONTACT"
End Sub

sub ContactDetail 'DO NOT CHANGE
Application.BasicFunctions.ShowViewForRecord "CONTACT","system:Contact Detail", DataGrid2.GetCurrentField("CONTACTID")
End Sub

Sub AXFormKeyPress(Sender, ByRef Key)
call SearchClick(Parent)
End Sub

Sub NewContactTicket
Dim objMainView, objAccountDetail, oA, oB
Set objMainView = Application.MainViews.Add("System:Insert New Ticket - Account Service Information", 0, False) 'DNL
objMainView.Caption = Application.Translator.Localize("Insert New Ticket - Account Service Information")
objMainView.Height = 590
objMainView.Width = 590
objMainView.BorderStyle = 3
Set objAccountDetail = objMainView.DetailsView
objAccountDetail.Script.Init "Insert", DataGrid2.GetCurrentField("ACCOUNTID") 'DNL
oA= DataGrid2.GetCurrentField("CONTACTID") 'DNL
oB= DataGrid2.GetCurrentField("LASTNAME") & ", " & DataGrid2.GetCurrentField("FIRSTNAME")
InsertNewContactTicket True, objAccountDetail,oA,oB
End Sub
Sub InsertNewContactTicket(blnAccntService, objAccountDetail,oA,oB)
Dim objMainView2, objDetail

Set objMainView2 = Application.MainViews.Add("System:Insert New Ticket", 2, False) 'DNL
objMainView2.Caption = Application.Translator.Localize("Insert New Ticket")
objMainView2.Height = 575
objMainView2.Width = 665

Set objDetail = objMainView2.DetailsView
If objDetail.lveAccount.Enabled Then
objDetail.lveAccount.LookupID = objAccountDetail.lveAccount.LookupID
objDetail.lveAccount.Text = objAccountDetail.lveAccount.Text
End If
objDetail.lveContact.LookupID = oA
objDetail.lveContact.Text = oB

objDetail.chkSubmitSearch.Checked = SetSearchDefault()
objMainView2.Show
End Sub

Sub NewContactOpportunity
Dim objMainView, objAccountDetail
Set objMainView = Application.MainViews.Add("System:Insert Opportunity", 0, False)
objMainView.Caption = Application.Translator.Localize("Insert Opportunity")
objMainView.Height = 642
objMainView.Width = 875
objMainView.BorderStyle = 3
Set objAccountDetail = objMainView.DetailsView
objAccountDetail.lveAccount.LookupID=DataGrid2.GetCurrentField("ACCOUNTID")
objAccountDetail.lveAccount.Text=DataGrid2.GetCurrentField("ACCOUNT")
CallInsertNewContactOpportunityView True, objAccountDetail
End Sub
Sub CallInsertNewContactOpportunityView(blnAccntService, objAccountDetail)
Dim objMainView2, objDetail

Set objMainView2 = Application.MainViews.Add("System:Insert Opportunity", 2, False)
objMainView2.Caption = Application.Translator.Localize("Insert Opportunity")
objMainView2.Height = 642
objMainView2.Width = 875

Set objDetail = objMainView2.DetailsView

If objDetail.lveAccount.Enabled Then
objDetail.lveAccount.LookupID = objAccountDetail.lveAccount.LookupID
objDetail.lveAccount.Text = objAccountDetail.lveAccount.Text
End If
objMainView2.Show
End Sub

Sub DataGrid1RowSelect(Sender)
accountid.text=DataGrid1.GetCurrentField("ACCOUNTID")
'application.BasicFunctions.SetCurrentAccountID DataGrid1.GetCurrentField("ACCOUNTID")

End Sub
________________________________________________________________________________
The link to insert new opportunity on an account doesnt pass the account info properly. If you get that working tell me how
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 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/27/2024 2:42:12 AM