Hi John,
It's a dreadful workaround, but what can you do when the
tool is missing the necessary pieces? This is what I do
for after load, but before user gets the form:
In the onLoad, create an error, e.g.
XDocument.Errors.Add(myfield, "SomeError", "add grp", "",
100, "modeless");
You'll have to play with the exact parameters to suit
yourself. myfields is the root node for the form xml,
i.e. something like:
myfield = XDocument.COM.selectSingleNode("/my:myFields");
as the error needs to be associated with some node, and
the top sounds good. You might want to use the node that
your adding to, instead!
Then in your taskpane, add an init handler and put code
there to loop through the errors and do the add when the
error exists. This assumes your onload actions may vary
based on some condition. If you are always going to do
this action, then just put it into the taskpane onload
handler and forget about the error. I use the error to
pass load success/fail state between the form onload and
the taskpane onload.
If there are multiple conditions, just add multiple
errors, with different codes, etc. then test for each and
carry out the necessary action! The error check code
would be something like:
var item = 0;
while (i < gXDoc.Errors.Count() {
var err = gXDoc.Errors.Item(i);
if (err.Type=='USER_SPECIFIED' && err.ErrorCode==100) {
// do something here now we've found the error
// remove the error - its only an event mechanism
gXDoc.Errors.Delete(err.node, err.ConditionName);
} else i++;
}
You ALWAYS have a taskpane (view), but you may not have a
taskpane.html, if not (I'm not sure if it's created with
a new form), create one, add it to the form resources and
setup the onInit, as you would with a regular
html/javascript combination. Then put your code there,
for example:
<html>
<script>
var gXDoc = window.external.XDocument;
function init() { // do add repeat }
</script>
<body onLoad="init()">
Just some explanatory text about the form
</body>
</html>
The taskpane onload always gets invoked after load, but
has the advantage of being able to access the XDocument.
This isn't a perfect situation, but its been working for
me!
HTH
Perry
-----Original Message-----
In my OnAfterChange eventhandler I use the following code and it works just
fine:
thisXDocument.View.ExecuteAction
("xCollection::insert", "group_1");