DannyC wrote:I am using the following line to fire a Private Sub
AddHandler salesOrderForm.SalesOrder.SalesOrderLineRemoving, AddressOf DeleteLine
but the line
Private Sub DeleteLine(sender As Object, e As System.EventArgs )
is giving a compile error
Method 'Private Sub DeleteLine(sender As Object, e As System.EventArgs )' does not have a signature compatible with delegate 'Delegate Sub SalesOrderLineRemoving...
That event signature looks like this:
- Code: Select all
Public Event SalesOrderLineRemoving(sender As Object, e As System.EventArgs, ByVal item As SalesOrderLine)
So just add the last parameter and you should be working. We left that event there simply as a compatibility bridge from V6 script - you can also use the salesOrderForm.SalesOrder.SalesOrderLines.Removing event - which is much the same, but is consistent with our standard design pattern.
DannyC wrote:I basically need a way to back out of the line delete, a bit like the old RtnCancel. I've seen a previous suggestion elsewhere just to do another Read request, but I don't want to read the Sales Order again, I just want to get back to the line state before the delete event.
Cheers
Throw a JiwaApplication.Exceptions.ClientCancelled exception to behave like the old rtnCancel of V6.
As for the permissions:
1. Insert an abstract permission into the table:
- Code: Select all
INSERT INTO SY_FormsAbstractPermissions(RecID, SY_Forms_ClassName, Name, Description, ItemNo)
SELECT NewID(), 'JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm', 'Remove Sales Order Line', 'Allow removal of sales order lines',
(SELECT MAX(ItemNo) + 1 FROM SY_FormsAbstractPermissions WHERE SY_Forms_ClassName = 'JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm')
2. Add the plugin code to examine the permission when a delete of a line is starting and throw a clientcancelled if no permission
- Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
Dim salesOrderForm As JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
AddHandler salesOrderForm.SalesOrder.SalesOrderLines.Removing, AddressOf SalesOrderLines_Removing
End Sub
Public Sub SalesOrderLines_Removing(SalesOrderLine As JiwaSales.SalesOrder.SalesOrderLine)
Dim permission As JiwaApplication.Security.UserGroup.AccessLevels = JiwaApplication.Manager.Instance.Staff.GetAbstractPermission("JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm", "Remove Sales Order Line")
If permission <> JiwaApplication.Security.UserGroup.AccessLevels.Allow Then
Throw New JiwaApplication.Exceptions.ClientCancelledException
End If
End Sub
3. Set the permissions - on the sales order entry form, utilities ribbon tab - choose Set Permissions then select the Abstract Permissions tab and locate the new permission "Remove Sales Order Line" - set the permission and save. Remember permissions are masked together for all groups the staff member belongs to, as well as the Default Abstract permission.
- Abstract Permissions
For completeness a plugin is attached demonstrating this.
Mike