Stitch Update Trigger on Subdocument

Hi there,

This seems really silly but I just can’t figure it out. I want my update stitch trigger to fire on a nested field, is that possible?

My particular use case is field subscriptionStatus in object subscription.
I’ve tried:
{"updateDescription.updatedFields": {"subscription.subscriptionStatus":"current"} }
and
{"updateDescription.updatedFields.subscription.subscriptionStatus":"current"}
But neither fire, despite when removing the match expression and logging the result of the expected update gives:
{"removedFields":[],"updatedFields":{"subscription.endDate":"2020-06-07T12:02:10.440Z", "subscription.subscriptionStatus":"current"}...}
So it’s definitely there, what am I missing?
Thanks in advance

Hi Carla – I believe the correct match syntax is as follows, can you try this and let me know if it works –

{
  "updateDescription": {
    "updatedFields": {
      "subscription": {
        "subscriptionStatus":"current" 
      }
    }
  }
}
1 Like

Hi @Drew_DiPalma, how can this solution be adopted to work with $or? I have a very similar problem and the only difference is that I want to watch for 2 possible values of my own equivalent of @Carla_Wilby 's subscriptionStatus. So consider if Carla needed the trigger to fire when subscriptionStatus is either "current" or "pending". How would that work? I tried adjusting your solution like this (but it doesn’t work):

{
  "$or": [{
    "updateDescription": {
      "updatedFields": {
        "subscription": {
          "subscriptionStatus":"current" 
        }
      }
    }
  },
  {
    "updateDescription": {
      "updatedFields": {
        "subscription": {
          "subscriptionStatus":"pending" 
        }
      }
    }
  }]
}

What’s the correct way to achieve this? Thanks!

2 posts were split to a new topic: Limiting a trigger based on the update belonging to a specific field of a subdocument

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.