Rules are a quick way to add dynamic functionality to a form, so a lot of programmers choose to use rules even when they know how to write the code to do the same thing. However, sometimes after writing a complex set of rules they may realize that they need to do something rules doesn’t support, and we know they don’t want to rewrite all their rules in code just to add that one little bit.
Alas, there’s no rules action type for “Call code”, but there is a roundabout way to call your code anyway.
Let’s say you have the following function in your form template:
Function Test(param) XDocument.UI.Alert("Param: " & param) Test = trueEnd Function
function Test(param) { XDocument.UI.Alert("Param: " + param); return true;}
Public Function Test(ByVal param As String) As Boolean thisXDocument.UI.Alert("Param: " & param) Test = TrueEnd Function
public boolean Test(string param) { thisXDocument.UI.Alert("Param: " + param); return true;}
You can call that function from the condition of a rule by using the xdExtension namespace.
For example, here’s how to call the function from a rule when the form is opened:
Finally, extract your form files and add the following attribute to the manifest.xsf file’s xDocumentClass element:
xmlns:xdExtension="http://schemas.microsoft.com/office/infopath/2003/xslt/extension"
IP2007 - I though this could be a work around for an issue, but I'm having a failure within my code.
Is it possible to have a DataConnection.Execute() in the function call when used in this context?
TIA,
Terry
Does IP Forms Service Support this construct?
Also, IP2007 seems to have the xdExtension pre defined.
On MOSS form services upload/Verify:
The upload process returns the following Validation error:
manifest.xsf
The following expression could not be parsed because of a syntax error
or because it uses an undefined namespace prefix or unsupported
function: xdExtension:of_PreSave("foo").
Location: manifest.xsf
Is this supported in IP2010?
yes, this is still supported