Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setPostTriggerInclude doesn't set context response? #23

Open
zxm5010 opened this issue May 7, 2021 · 0 comments
Open

setPostTriggerInclude doesn't set context response? #23

zxm5010 opened this issue May 7, 2021 · 0 comments

Comments

@zxm5010
Copy link

zxm5010 commented May 7, 2021

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):

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant