CadConnector can run scripts that stored in $CADENAS_SETUP\scripts\cadconnector\web
A method that can be run must be a function and take one context parameter.
Possible members of the context object so far are: Mident, DialogResult, DialogDefinition, MailTemplate, ErrorDetails.
There are multiple use cases when such a function can be called, e.g., to verify/enrich the data of the add2db dialog.
Add2db and request per Mail dialog hooks can be configured in erpcustom.cfg:
[WEB_CALLBACKS] BeforeShowModule= BeforeShowFunction= BeforeCommitModule= BeforeCommitFunction=
You must specify the name of the vbs/vbb file under $CADENAS_SETUP\scripts\cadconnector\web
, and the name of the function to be called.
The before show hook could modify the data/structure of the dialog, and for example pre-fill values or even change the definition of the dialog, maybe by deactivating some fields. To do so, you have to access and modify the DialogDefinition member of the context parameter. See VBS documentation of prxWebDialog for details.
function PreProcessAdd2DbDialog(context) dim dlg = context.DialogDefinition dim priceField = dlg.GetRootContainer().FindElement("price") 'get price from SAP priceField.Value = CStr(25) set PreProcessAdd2DbDialog = dlg end function
The before commit hook can check the user inputs of the dialog via the DialogResult member. Look for prxWebDialogResult for details.
function VerifyInput(context) dim price = CInt(context.DialogResult.Values.Item("price")) if (price < 1000) then context.ErrorDetails = "Test error!" VerifyInput = false else VerifyInput = true end if end function
There are also other situations when a Web Dialog could be displayed. For example, OnExport callbacks in CadConnector (same as PSOL) could create a WebDialog (prxWebDialog) and let 3df display it by calling execute on it.
function OnExportCad() dim dlg = CreateObject("cnstools.webdialog") dlg.Title = "Enter value" dim container = dlg.getRootContainer() dim lbl = container.addLabel("lbl1") lbl.Label = "Value: " container.addTextEdit("id1") dlg.addButton("ok", "OK", "submit") dlg.addButton("cancel", "Cancel", "cancel") dim result = dlg.execute() stdprint(result.action) stdprint(result.values.Item("id1")) end function