This is an old revision of the document!
Limiting access to features
Prevent mass updates
Before the Mass update menu is shown a VBA event is triggered that allows customization of which fields or objects that can be updated or created. This event also receives information of which fields or objects that the user wants to update. The event has the following signature:
Innan Lime visar menyn Massuppdatera skickar den event till VBA för att få reda på vilka fält eller objekt som kan uppdateras eller skapas. Detta event skickar med det fält eller objekt som skapa uppdateras eller skapas och ser ut på följande vis:
Explorer.BeforeCommand(Command As CommandEnum, Parameter As Variant, Cancel As Boolean) •Command anger typ av kommando och har värdet lkCommandUpdateOption när det rör sig av massuppdatering.
•Parameter varierar i typ och beror på vad som ska massuppdateras. När ett fält ska massuppdateras är Parameter ett objekt typen LDE.Field och anger helt vilket fält det gäller.
När nya objekt ska skapas är Parameter ett objekt av typen LDE.IProperties och innehåller namngivna parametrar. TargetClass är ett objekt av typen LDE.IClass och anger typ av objekt som ska skapas. SourceClass är objekt av typen LDE.IClass och anger typ av objekt som används som datakälla och som de nya objektet ska kopplas till.
•Cancel som är flagga som låter dig bestämma om fliken ska visas i menyn eller inte. Sätter du den till False (vilket är standardvärdet för de flikar Lime visar som standard) så läggs fliken till i menyn annars inte.
Följande exempel låter användarna uppdatera standardflikarna plus personfliken från företagslistan:
Private Sub Explorer_BeforeCommand(Command As CommandEnum, Parameter As Variant, Cancel As Boolean) ' Kontrollera att det är rätt kommando If Command = lkCommandUpdateOption Then ' Gäller det fält If TypeOf Parameter Is LDE.Field Then ' Tillåt inte fält som börjar på A If Left(Parameter.LocalName, 1) = "A" Then Cancel = True End If ' Gäller det nya objekt If TypeOf Parameter Is LDE.Properties Then ' Kontrollera att vi utgår från företagsfliken If Parameter.Get("SourceClass").LocalName = "Företag" Then ' Ändra inte flaggan för standardflikar If Cancel = True Then ' Tillåt om det är personfliken If Parameter.Get("TargetClass").LocalName = "Person" Then Cancel = False End If End If End If End If End If End Sub
Prevent Excel export
Before and after certain commands are executed in LIME Pro, VBA events that can be listened to are triggered. These events are named Explorer_BeforeCommand
and Explorer_AfterCommand
.
The following example disables usage of the Export to Excel feature:
Private WithEvents m_Explorer As Lime.Explorer Private Sub Application_AfterActiveExplorerChanged() Set m_Explorer = Application.ActiveExplorer End Sub Private Sub m_Explorer_BeforeCommand(ByVal Command As CommandEnum, ByVal Parameter As Variant, Cancel As Boolean) If Command = lkCommandExportToExcel Then MsgBox "Detta tillåter jag inte.", vbInformation Cancel = True End If End Sub
Hiding inspector toolbar buttons
It is possible to hide certain buttons in the explorer toolbar by modifing the Explorer.Settings
collection. The following example hides the Link record button for the Persons tab (if one exists):
Private WithEvents m_Inspector As Lime.Inspector Private Sub Application_BeforeActiveInspectorChanged(ByVal NextInspector As IInspector) Set m_Inspector = NextInspector End Sub Private Sub m_Inspector_BeforeShow(Cancel As Boolean) If m_Inspector.Explorers.Exists("persons") Then m_Inspector.Explorers("persons").Settings.Write "DisableLink", True End If End Sub
The following buttons can be modified:
Identifier | Button |
---|---|
DisableLink | Link record |
DisableUnlink | Unlink record |
DisableNew | New record |
DisableDelete | Delete record |
DisableOpenDocument | Open document |
To show the button set the value to False
.
Prevent hiding of tabs and fields
Users may normally individually configure which fields and tabs that are visible. To prevent this behavior the following VBA code can be used:
Application.Database.Settings.Item("Application").Value("DisableInspectorLayout") = True
This can also be done for a specific database class, company in this case:
Application.Database.Settings.Item("Inspectors").Item(Application.Database.Classes("company").GUID).Value("DisableLayout") = True
Note
If users have already used the show/hide fields/tabs feature there is a risk that they have already hidden tabs and/or fields and then after disabling the feature will not be able to restore the visibility settings.