I'm trying to use setPostTriggerInclude to run a post-trigger after a document added. However, I'm getting null from context.getResponse()
Post-trigger javascript (myPostTrigger):
function myPostTrigger() {
var context = getContext();
var container = context.getCollection();
var response = context.getResponse(); // item that was created
var createdItem = response.getBody();
// we are hitting this check
if(!createdItem) throw new Error("No created item from hooked action.")
}
Java
JsonNode jsonNode = new ObjectMapper().valueToTree(item);
// Create item using container
List<String> postTriggers = new ArrayList<>();
postTriggers.add("myPostTrigger");
CosmosItemRequestOptions cosmosItemRequestOptions = new CosmosItemRequestOptions()
.setPostTriggerInclude(postTriggers);
logger.info("itemInJson : " + jsonNode.toString());
CosmosItemResponse<JsonNode> response = cosmosDbContainer.getContainer().createItem(jsonNode, cosmosItemRequestOptions);
I can confirm that the createItem creates document properly without the postTrigger set.
Hi,
I'm trying to use setPostTriggerInclude to run a post-trigger after a document added. However, I'm getting null from context.getResponse()
Post-trigger javascript (myPostTrigger):
Java
I can confirm that the createItem creates document properly without the postTrigger set.