Hello. Today I needed to implement a little checkbox in Saleslogix with a little twist. This checkbox must remember its value according to the user that is currently using it. In other words, if a user checks this box and then closes his SLX client, the checkbox must be checked the next time the user navigates to it.
This should be – like I said – user-dependent. Every user should be able to decide in which state he / she wants to operate the checkbox.
Saleslogix offers such methods out of the box. No creation of corresponding database tables and manual manipulation of values. This is done by using the embedded Application.UserOptions methods.
Inside the OnFormChange event, we check if the values exist and if so, we set them for the current instance:
(The primary key consists of the combination of the two strings inside the “Exists” statement, in our case “hideTestCheckBox” and “LicenseContact + UserID”)
In the event where the checkbox gets updated, we need to push the updated value in the User Options. This is done as such:
Obviously we need to add the key to the database in case it is not there yet. The first “IF” statement is run only once here per user. But this is mandatory, otherwise SLX throws an exception that the key is missing.
Cheers!
This should be – like I said – user-dependent. Every user should be able to decide in which state he / she wants to operate the checkbox.
Saleslogix offers such methods out of the box. No creation of corresponding database tables and manual manipulation of values. This is done by using the embedded Application.UserOptions methods.
Inside the OnFormChange event, we check if the values exist and if so, we set them for the current instance:
if Application.UserOptions.Exists("hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID) = true then
hideTestCheckBox.Checked = Application.UserOptions.GetAsBoolean("hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID)
End If
Pay attention to the “Application.BasicFunctions.CurrentUserID” modifier for the CATEGORY KEY of the UserOption. Actually, the name UserOptions is not appropriate here since these keys are actually common for all users. Thus, we need to concatenate the group key with the current user ID to avoid exceptions trying to push entries with the same Primary key in SLX DB.(The primary key consists of the combination of the two strings inside the “Exists” statement, in our case “hideTestCheckBox” and “LicenseContact + UserID”)
In the event where the checkbox gets updated, we need to push the updated value in the User Options. This is done as such:
Sub hideTestCheckBoxClick(Sender)
if Application.UserOptions.Exists("hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID) = false then
Application.UserOptions.Add "hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID, "Hide Test Licenses", hideTestCheckBox.Checked
end if
Application.UserOptions.SetAsBoolean "hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID, hideTestCheckBox.Checked, false
UpdateDataGrid
End Sub
Obviously we need to add the key to the database in case it is not there yet. The first “IF” statement is run only once here per user. But this is mandatory, otherwise SLX throws an exception that the key is missing.
Cheers!
No comments:
Post a Comment