The
CadConnector can run scripts that run in $CADENAS_SETUP\scripts\cadconnector\web
are filed.
A method that can be run must be a function and take a "context" parameter.
Possible parts (members) of the "Context" object are as follows: Mident, DialogResult, DialogDefinition, MailTemplate, ErrorDetails
There are various use cases when such a function can be called, e.g. to verify/enrich the data of the "add2db" dialog.
Hooks
to "Add2db" and "request by mail" dialogs can be configured in erpcustom.cfg
become:
[WEB_CALLBACKS] BeforeShowModule= BeforeShowFunction= BeforeCommitModule= BeforeCommitFunction=
They
must specify the name of the vbs/vbb file and the name of the function to be called
under $CADENAS_SETUP\scripts\cadconnector\web
specify.
The previously shown "Hook" could modify data/structure of the dialog and e.g. prefill values or even change the definition of the dialog, possibly by deactivating some fields. To do this, you need to modify the "DialogDefinition" part of the "context" parameter. For details, see the VBS documentation of the "prxWebDialog".
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 previously passed "Hook" can check the user input of the dialog using the DialogResult part. For details, see prxWebDialogResult.
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 cause 3Dfindit to display it through an Execute call.
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
