nmarus / node-ews

A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API.
MIT License
116 stars 52 forks source link

FindItem with Or in restriction not working as expected #135

Closed gilruben closed 3 years ago

gilruben commented 3 years ago

Hi Everyone,

I'm try to execute the FindItem function with the arguments below. As you can see, I have an Or in the restriction and two Contains search expressions inside of the Or. The issue I'm having is that only the first Contains is being respected. The other is ignored. Does anyone know why this is happening?


{
  attributes: {
    Traversal: 'Shallow',
  },
  ItemShape: {
    BaseShape: 'Default',
  },
  ParentFolderIds: {
    DistinguishedFolderId: {
      attributes: {
        Id: 'inbox',
      },
    },
  },
  Restriction: {
    't:Or': [
      {
        't:Contains': {
          attributes: {
            ContainmentMode: 'Substring',
            ContainmentComparison: 'IgnoreCase'
          },
          't:FieldURI': {
            attributes: {
              FieldURI: 'item:Body'
            }
          },
          't:Constant': {
            attributes: {
              Value: 'p6-'
            }
          }
        }
      },
      {
        't:Contains': {
          attributes: {
            ContainmentMode: 'Substring',
            ContainmentComparison: 'IgnoreCase'
          },
          't:FieldURI': {
            attributes: {
              FieldURI: 'item:Subject'
            }
          },
          't:Constant': {
            attributes: {
              Value: 'p6-'
            }
          }
        }
      }
    ]
  }
}
gilruben commented 3 years ago

A coworker of mine, @elopez89, figured this out. It works when I change the restriction to the code below.


{
  't:Or': {
    't:Contains': [
      {
        attributes: {
          ContainmentMode: 'Prefixed',
          ContainmentComparison: 'IgnoreCase'
        },
        't:FieldURI': {
          attributes: {
            FieldURI: 'item:Body'
          }
        },
        't:Constant': {
          attributes: {
            Value: 'p6-'
          }
        }
      },
      {
        attributes: {
          ContainmentMode: 'Prefixed',
          ContainmentComparison: 'IgnoreCase'
        },
        't:FieldURI': {
          attributes: {
            FieldURI: 'item:Subject'
          }
        },
        't:Constant': {
          attributes: {
            Value: 'p6-'
          }
        }
      }
    ]
  }
}