6/20/2025 10:35:46 AM
|
|
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!
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.
|
|
|
|
Can I programattically move to the next record in an account lookup?
Posted: 24 Aug 07 9:43 AM
|
Hello,
Does anyone know how to programattically move to the next record in an account lookup?
Some background Info:
When users delete an account record, I want to hide the record by changing the SeccodeID to a user called "Purged Accounts". This way, the account will no longer be visible to the user, but I can have some control over when the record is actually removed from the database.
When I change the SeccodeID on an account to that of the "Purged Accounts" user, I am receiving a message stating "You do not have access to this account" and the record detail is now blank for the "deleted" record. To prevent this, I would like to advance to the next record in the lookup before changing the seccodeid.
Any help will be appreciated.
Thank you, ...Rob
|
|
|
| |
|
Re: Can I programattically move to the next record in an account lookup?
Posted: 27 Aug 07 8:24 AM
|
Hello Stephen,
Thanks for the reply. First let me specify that I'm using version 6.2.6 so that may or may not limit my options.
After I change the seccodeid to hide the record, I do a refresh. I've tried both Application.MainViews.ActiveView.Refresh and Application.BasicFunctions.RefreshMainView. When the refresh is complete, the end user gets the message "You do not have access to this account", which makes sense because I changed the Secodeid to hide the record. Upon a refresh, the currentid is still the ID of the hidden record and the view tries to re-display that record. I need to change the currentid before refreshing so the refresh doesn't try to display the hidden record. I just don't know what to change it to. I would like to change it to the next record if one exists, but what is the next record?
Thanks again for your help. |
|
|
| |
|
Re: Can I programattically move to the next record in an account lookup?
Posted: 27 Aug 07 9:28 AM
|
Thank you Frank.
I might be missing something, but the GetGroupIDs requires that a groupID is passed and when a user just does a quick lookup, the results are returned to the "Lookup Results" group, which doesn't have a groupID, at least GetCurrentGroupID isn't returning a groupID. It seems that the Group functions only work saved groups.
Is there is a way to address the "Lookup Results" group in the GetGroupIDs function?
|
|
|
|
Re: Can I programattically move to the next record in an account lookup?
Posted: 27 Aug 07 4:55 PM
|
Hi,
This, or a variant of it, may work for you. It is my implementation of a MoveNext function of a main view group.
Dim ID ID = Application.MainViews.ActiveView.CurrentID
Dim LastID, NextID LastID = "" for i = 0 to Application.MainViews.ActiveView.GroupsPane.IDs.Count -1 If ID = Application.MainViews.ActiveView.GroupsPane.IDs.Item(i) Then if i = Application.MainViews.ActiveView.GroupsPane.IDs.Count -1 Then NextID = LastID Else NextID = Application.MainViews.ActiveView.GroupsPane.IDs.Item(i+1) End if Exit For End if NextID = Application.MainViews.ActiveView.GroupsPane.IDs.Item(i) next
Application.GetNewConnection.Execute "UPDATE CONTACT SET SECCODEID = 'BLAH' WHERE CONTACTID = '" & ID & "' "
Application.MainViews.ActiveView.CurrentID = NextID
|
|
|
|
Re: Can I programattically move to the next record in an account lookup?
Posted: 28 Aug 07 8:57 AM
|
Thank you Stephen,
This is what I was looking for, but afer implementing the code, it's really slow to loop through all of the IDs, especially when the record to be deleted/hidden is near the end of say 1000 records. For now, I have it working using sendkeys. It's working quite nicely, but it is sendkeys and a I hope I dont' run into any issues.
Thanks again for all your help.
...Rob |
|
|
|
Re: Can I programattically move to the next record in an account lookup?
Posted: 28 Aug 07 9:45 AM
|
For those who might be looking for the same, here is the the code I wrote using SendKeys
FYI: I created the costants dtACCOUNT = 1 , dtCONTACT = 2, and dtOPPORTUNITY =3 that are used in my Delete Tools include of which this function is part of.
Function MoveToNextRecord
Dim strViewID Dim intEntityType Dim intDisplayMode Dim DetailsView Dim strTmpID
strViewID = Application.BasicFunctions.CurrentViewID ' Get the ID of the current record if Len(trim(strViewID)) = 0 then Exit Function
intEntityType = CurrentEntityType(strViewID) 'I determine what they user is looking at from the ID intDisplayMode = Application.MainViews.ActiveView.DisplayMode DetailsView = Application.MainViews.ActiveView.DetailsView strTmpID = Application.MainViews.ActiveView.CurrentID
'First try to move to the next record. if intDisplayMode = 1 or intDisplayMode = 3 Then '1 = Detail, 3 = SplitView Select Case intEntityType Case dtACCOUNT DetailsView.txtAccount.setfocus Case dtCONTACT DetailsView.edtDepartment.setfocus Case dtOPPORTUNITY DetailsView.txtOpportunity.setfocus End Select SendKeys "Saleslogix","{PGDN}" Elseif intDisplayMode = 2 Then '2 = ListView SendKeys "Saleslogix","{DOWN}" End If Application.BasicFunctions.ProcessWindowMessages
'If that doesn't work (because the last record is beging deleted) try to move to the previous record if strTmpID = Application.MainViews.ActiveView.CurrentID Then 'indicates that the last record in the lookup is being deleted if intDisplayMode = 1 or intDisplayMode = 3 Then '1 = Detail, 3 = SplitView Select Case intEntityType Case dtACCOUNT DetailsView.txtAccount.setfocus Case dtCONTACT DetailsView.edtDepartment.setfocus Case dtOPPORTUNITY DetailsView.txtOpportunity.setfocus End Select SendKeys "Saleslogix","{PGUP}" Elseif intDisplayMode = 2 Then '2 = ListView SendKeys "Saleslogix","{UP}" End If Application.BasicFunctions.ProcessWindowMessages End IF
'IF that doesn't work (becuase the only record in the lookup is being deleted) just set the ID to "" if strTmpID = Application.MainViews.ActiveView.CurrentID Then 'At this point, indicates that ther is only one record in the loop Application.MainViews.ActiveView.CurrentID = "" Select Case intEntityType Case dtACCOUNT Application.BasicFunctions.SetCurrentAccountID "" Case dtCONTACT Application.BasicFunctions.SetCurrentContactID "" Case dtOPPORTUNITY Application.BasicFunctions.SetCurrentOpportunityID "" End Select End IF
MoveToNextRecord = Application.MainViews.ActiveView.CurrentID
End Function
|
|
|
|
Re: Can I programattically move to the next record in an account lookup?
Posted: 29 Aug 07 1:35 AM
|
Hi Rob Hi Stephen Has your article read but the modification of the SECCODEID on a contact shouldn't be made with a SQL instruction since other entries (History, Activities ect. ) depending on it.
It is better to change the SeccodeID in the account. I have program technically done that this way:
I have created a form (BASETABLE Account). I have taken a control element (TLookupEdit) there. Tip copies this control element (OWNER) out of the Form "ACCOUNT Details".
I've calling this form "WMSaveAccountOwner". Only the control element and no additional program code are in this form!!!
With this Function "ChangeAccountOwner" (see below), you can change the Account-Owner very easy. The dependent entries then are changed by the SLX system correctly. You can look at it also with the Profiler.
Function ChangeAccountOwner(SeccodeID, AccountID) Dim objMainView, PlugInName Dim mType
On Error Resume Next ChangeAccountOwner = False
PlugInName = "System:WMSaveAccountOwner"
Set objMainView = Application.MainViews.Add(PlugInName, 0, False) 'DNL objMainView.CurrentID = AccountID
objMainView.DetailsView.txtowner.LookupID = SeccodeID
objMainView.Post objMainView.Close
ChangeAccountOwner = True
Set objMainView = Nothing
End Function
Regards Frank Kress from Germany |
|
|
|
Re: Can I programattically move to the next record in an account lookup?
Posted: 29 Aug 07 12:48 PM
|
Thank you Frank. Unfortunately and account only delete/hide will not work, as users need to be able to delete/hide single contacts and opportunities as well as entire accounts.
My delete code handles the dependencies, such as when a user deletes/hides an account, I change the seccodeid on the account, contacts, and opportunities (we do not use tickets). When a contact is deleted/hidden, I change the seccodeid on all opportunities under that contact if they are the only contact on the opportunity. Notes/history records do not have seccodeID, at least not natively in 6.2.6, so I don't see this as a problem.
...Rob |
|
|
|
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!
|
|
|
|
|
|
|
|