We have a stored procedure that is modeled after the bulkImport sproc in the DocumentDB sample code. This sproc takes an array of documents, does some stuff, and eventually calls createDocument, which the documentation says is asynchronous.
Now we have written a pre-trigger for Create that checks some fields and optionally adds some additional fields to certain documents of the request.
{
"id":"triggerNameRedacted",
"triggerType": "Pre",
"triggerOperation": "Create",
"body": "function()
{
var context = getContext();
var request = context.getRequest();
var documentToCreate = request.getBody();
documentToCreate.msg = 'got to here';
request.setBody(documentToCreate);
}"
}
We attached this to the options
object we're passing to createDocument
in our sproc.
var options = {
disableAutomaticIdGeneration: false,
preTriggerInclude: 'triggerNameRedacted'
};
We expected to see the trigger being called. However, the trigger is not being fired. We have tried various modifications to try to see the trigger being fired, but it is still not: paring down the bulk sproc and the trigger to the absolute minimum, changing triggerOperation to "All".
In the source for the server-side wrapper, and in the docs for Collection linked above, it does not appear that the server-side code looks at any of the *Trigger*
fields of the options object, e.g. preTriggerInclude
as in our case.
Is it possible to have a pre-create trigger executed as a result of calling createDocument
within a stored procedure, or does the restriction against calling a stored procedure from another stored procedure apply to any server-side code?
Triggers can not be called from the server-side SDK (e.g. from inside another trigger or sproc).