Highlighted
Absent Member.
Absent Member.
1501 views

Filter on custom field not working

Hi,
I've spent a good amount of time pouring over the documentation and the forums for this one, but can't seem to figure it out.

I'm creating an archiving app that can restore archived items (mail messages) on the GW server, and gives them a custom field named "archive". It's a numeric field, set to "1". We've been reading from the mail store using a filter on the "created" field, and now I want to add a filter for the "archived" field so that we don't archive those mails twice.

From what I can gather from reading the examples, the way to construct the compound filter is as follows:

Filter gwFilter = new Filter();
FilterGroup gwFG = new FilterGroup();
FilterEntry[] gwFE = new FilterEntry[2];

gwFE[0] = new FilterEntry();
gwFE[0].setField("created");
gwFE[0].setValue("2010-09-17T00:00:00Z");
gwFE[0].setOp(FilterOp.GT);

gwFE[1] = new FilterEntry();
final Custom fwCustom = new Custom();
fwCustom.setField("archived");
fwCustom.setType(CustomType.NUMERIC);
fwCustom.setAdminOnly(true);
gwFE[1].setCustom(fwCustom);
gwFE[1].setOp(FilterOp.NOT_EXIST);

gwFG.setOp(FilterOp.AND);
gwFG.getElement().add(gwFE[0]);
gwFG.getElement().add(gwFE[1]);
gwFilter.setElement(gwFG);


You'll notice that it's more or less copy-pasted from the example code in the SOAP docs.

The problem is, that this doesn't work. For some reason, this filter finds all message that *do* have the custom field, even thought the Op is set to NOT_EXIST. The proof (SOAP trace) is listed below, where you can clearly see the filter with the NOT_EXIST op, and the subsequent response containing an item with exactly that field.

So my question is, how do I get this to work? How do I construct a filter that gets all messages after a certain timestamp, but without a certain field?

I noticed there was a similar question in the forums from around 2008, and that Preston had opened a bug for that issues. Has this been fixed?

Regards,
Maarten

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns3:createCursorRequest xmlns="http://schemas.novell.com/2005/01/GroupWise/types" xmlns:ns2="http://schemas.novell.com/2005/01/GroupWise/events" xmlns:ns3="http://schemas.novell.com/2005/01/GroupWise/methods">
<ns3:container>folders</ns3:container>
<ns3:view>peek message delivered subject hasAttachments priority size attachments custom email from default recipients sendoptions</ns3:view>
<ns3:filter>
<element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="FilterGroup">
<op>and</op>
<element xsi:type="FilterEntry">
<op>gt</op>
<field>created</field>
<value>2010-09-17T00:00:00Z</value>
</element>
<element xsi:type="FilterEntry">
<op>notExist</op>
<custom type="Numeric">
<field>archived</field>
<adminOnly>true</adminOnly>
</custom>
</element>
</element>
</ns3:filter>
</ns3:createCursorRequest>
</S:Body>
</S:Envelope>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header />
<S:Body>
<gwm:createCursorResponse xmlns:gwe="http://schemas.novell.com/2005/01/GroupWise/events" xmlns:gwm="http://schemas.novell.com/2005/01/GroupWise/methods" xmlns:gwt="http://schemas.novell.com/2005/01/GroupWise/types">
<gwm:cursor>-122826395</gwm:cursor>
<gwm:status>
<gwt:code>0</gwt:code>
</gwm:status>
</gwm:createCursorResponse>
</S:Body>
</S:Envelope>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns3:readCursorRequest xmlns="http://schemas.novell.com/2005/01/GroupWise/types" xmlns:ns2="http://schemas.novell.com/2005/01/GroupWise/events" xmlns:ns3="http://schemas.novell.com/2005/01/GroupWise/methods">
<ns3:container>folders</ns3:container>
<ns3:cursor>-122826395</ns3:cursor>
<ns3:forward>true</ns3:forward>
<ns3:count>1000</ns3:count>
</ns3:readCursorRequest>
</S:Body>
</S:Envelope>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header />
<S:Body>
<gwm:readCursorResponse xmlns:gwe="http://schemas.novell.com/2005/01/GroupWise/events" xmlns:gwm="http://schemas.novell.com/2005/01/GroupWise/methods" xmlns:gwt="http://schemas.novell.com/2005/01/GroupWise/types">
<gwm:items>
<gwt:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="gwt:Mail">
<gwt:id>4C98CFA7.s1tv.fantasticpo.100.1757630.1.50D0.1@1:4A952666.s1tv.fantasticpo.100.1757630.1.5070.1@13</gwt:id>
<gwt:version>3</gwt:version>
<gwt:modified>2010-09-21T13:30:56Z</gwt:modified>
<gwt:container>4A952666.s1tv.fantasticpo.100.1757630.1.5070.1@13</gwt:container>
<gwt:created>2010-09-17T12:29:55Z</gwt:created>
<gwt:customs>
<gwt:custom type="Numeric">
<gwt:field>archived</gwt:field>
<gwt:value>1</gwt:value>
</gwt:custom>
</gwt:customs>
<gwt:status />
<gwt:msgId>4C98CFA7.s1tv.fantasticpo.200.200007E.1.528.1</gwt:msgId>
<gwt:source>received</gwt:source>
<gwt:delivered>2010-09-17T12:29:55Z</gwt:delivered>
<gwt:security>Normal</gwt:security>
<gwt:subject>test</gwt:subject>
<gwt:distribution>
<gwt:from>
<gwt:displayName>Wayne rooney</gwt:displayName>
<gwt:email>wayne@fantastic.socs.lan</gwt:email>
<gwt:uuid>59A83700-1732-0000-8576-D999178DF7D8</gwt:uuid>
</gwt:from>
<gwt:to>Alex ferguson</gwt:to>
<gwt:recipients>
<gwt:recipient>
<gwt:displayName>Alex ferguson</gwt:displayName>
<gwt:email>alex@fantastic.socs.lan</gwt:email>
<gwt:uuid>92481080-1732-0000-8576-D999178DF7D8</gwt:uuid>
<gwt:distType>TO</gwt:distType>
<gwt:recipType>User</gwt:recipType>
</gwt:recipient>
</gwt:recipients>
<gwt:sendoptions>
<gwt:statusTracking>None</gwt:statusTracking>
</gwt:sendoptions>
</gwt:distribution>
<gwt:message>
<gwt:part contentType="text/plain" length="160">e1xydGYxXGRlZmYwe1xmb250dGJse1xmMFxmbmlsXGZjaGFyc2V0MSBUYWhvbWE7fX17XHN0eWxlc2hlZXR7XGZzMTYgR3JvdXBXaXNlVmlldzt9fVxmczE2IGFzZGZhc2RmIHNhZGYgYXNkZiBzZCBhYSBkfQ==</gwt:part>
</gwt:message>
<gwt:attachments>
<gwt:attachment>
<gwt:id>4C98CFA7.s1tv.fantasticpo.200.200007E.1.525.1@45:4C98CFA7.s1tv.fantasticpo.100.1757630.1.50D0.1@1:4A952666.s1tv.fantasticpo.100.1757630.1.5070.1@13</gwt:id>
<gwt:name>TEXT.htm</gwt:name>
<gwt:contentType>TEXT/HTML</gwt:contentType>
<gwt:size>237</gwt:size>
<gwt:date>2010-09-17T14:29:49Z</gwt:date>
<gwt:hidden>1</gwt:hidden>
</gwt:attachment>
<gwt:attachment>
<gwt:id>4C98CFA7.s1tv.fantasticpo.200.200007E.1.526.1@45:4C98CFA7.s1tv.fantasticpo.100.1757630.1.50D0.1@1:4A952666.s1tv.fantasticpo.100.1757630.1.5070.1@13</gwt:id>
<gwt:name>Water lilies.jpg</gwt:name>
<gwt:contentType>image/jpeg</gwt:contentType>
<gwt:size>83794</gwt:size>
<gwt:date>2010-09-17T14:29:49Z</gwt:date>
<gwt:hidden>0</gwt:hidden>
</gwt:attachment>
</gwt:attachments>
<gwt:options>
<gwt:priority>Standard</gwt:priority>
</gwt:options>
<gwt:hasAttachment>1</gwt:hasAttachment>
<gwt:size>84918</gwt:size>
</gwt:item>
</gwm:items>
<gwm:status>
<gwt:code>0</gwt:code>
</gwm:status>
</gwm:readCursorResponse>
</S:Body>
</S:Envelope>
Labels (1)
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

You might think that, if NOT_EXISTS actually returns the messages that *do* have the field, EXISTS might, paradoxically, return those that *don't*. Unfortunately this isn't the case. The same SOAP requests as listed above using EXISTS as the Op simply return nothing at all.
0 Likes
Highlighted
Absent Member.
Absent Member.

If you use FilterOp.exists, the field has to be the only element.
You will have to test for a value if you want to combine it with
another element. Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns0="http://schemas.novell.com/2005/01/GroupWise/methods">
<env:Body>
<ns0:getItemsRequest>
<ns0:container>7.domain.PO1.100.0.1.0.1@16</ns0:container>
<ns0:filter>
<ans1:element
xmlns:ans1="http://schemas.novell.com/2005/01/GroupWise/types"
xsi:type="ans1:FilterGroup">
<ans1:op>and</ans1:op>
<ans1:element xsi:type="ans1:FilterEntry">
<ans1:op>eq</ans1:op>
<ans1:custom type="String">
<ans1:field>Mail Stop</ans1:field>
</ans1:custom>
<ans1:value>756</ans1:value>
</ans1:element>
<ans1:element xsi:type="ans1:FilterEntry">
<ans1:op>gt</ans1:op>
<ans1:field>created</ans1:field>
<ans1:value>2010-09-22T12:25:31Z</ans1:value>
</ans1:element>
</ans1:element>
</ns0:filter>
<ns0:count>0</ns0:count>
</ns0:getItemsRequest>
</env:Body>
</env:Envelope>

Note: You should consider using the retention option.
If you set an retention date and enable smart purge,
The POA will not allow items to be purged until after
you have saved off the items. You then search for items
that have a delivered date greater than the last
retention date.

Preston

>>> On Tuesday, September 21, 2010 at 8:06 AM,

mdirkse<mdirkse@no-mx.forums.novell.com> wrote:

> Hi,
> I've spent a good amount of time pouring over the documentation and the
> forums for this one, but can't seem to figure it out.
>
> I'm creating an archiving app that can restore archived items (mail
> messages) on the GW server, and gives them a custom field named
> "archive". It's a numeric field, set to "1". We've been reading from the
> mail store using a filter on the "created" field, and now I want to add
> a filter for the "archived" field so that we don't archive those mails
> twice.
>
> From what I can gather from reading the examples, the way to construct
> the compound filter is as follows:
>
> Code:
> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
>
> Filter gwFilter = new Filter();
> FilterGroup gwFG = new FilterGroup();
> FilterEntry[] gwFE = new FilterEntry[2];
>
> gwFE[0] = new FilterEntry();
> gwFE[0].setField("created");
> gwFE[0].setValue("2010‑09‑17T00:00:00Z");
> gwFE[0].setOp(FilterOp.GT);
>
> gwFE[1] = new FilterEntry();
> final Custom fwCustom = new Custom();
> fwCustom.setField("archived");
> fwCustom.setType(CustomType.NUMERIC);
> fwCustom.setAdminOnly(true);
> gwFE[1].setCustom(fwCustom);
> gwFE[1].setOp(FilterOp.NOT_EXIST);
>
> gwFG.setOp(FilterOp.AND);
> gwFG.getElement().add(gwFE[0]);
> gwFG.getElement().add(gwFE[1]);
> gwFilter.setElement(gwFG);
> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
>
>
> You'll notice that it's more or less copy‑pasted from the example code
> in the SOAP docs.
>
> The problem is, that this doesn't work. For some reason, this filter
> finds all message that *do* have the custom field, even thought the Op
> is set to NOT_EXIST. The proof (SOAP trace) is listed below, where you
> can clearly see the filter with the NOT_EXIST op, and the subsequent
> response containing an item with exactly that field.
>
> So my question is, how do I get this to work? How do I construct a
> filter that gets all messages after a certain timestamp, but without a
> certain field?
>
> I noticed there was a similar question in the forums from around 2008,
> and that Preston had opened a bug for that issues. Has this been fixed?
>
> Regards,
> Maarten
>
> Code:
> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
>
> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
> <S:Body>
> <ns3:createCursorRequest
> xmlns="http://schemas.novell.com/2005/01/GroupWise/types"
> xmlns:ns2="http://schemas.novell.com/2005/01/GroupWise/events"
> xmlns:ns3="http://schemas.novell.com/2005/01/GroupWise/methods">
> <ns3:container>folders</ns3:container>
> <ns3:view>peek message delivered subject hasAttachments priority size
> attachments custom email from default recipients sendoptions</ns3:view>
> <ns3:filter>
> <element xmlns:xsi="http://www.w3.org/2001/XMLSchema‑instance"
> xsi:type="FilterGroup">
> <op>and</op>
> <element xsi:type="FilterEntry">
> <op>gt</op>
> <field>created</field>
> <value>2010‑09‑17T00:00:00Z</value>
> </element>
> <element xsi:type="FilterEntry">
> <op>notExist</op>
> <custom type="Numeric">
> <field>archived</field>
> <adminOnly>true</adminOnly>
> </custom>
> </element>
> </element>
> </ns3:filter>
> </ns3:createCursorRequest>
> </S:Body>
> </S:Envelope>
> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
> <S:Header />
> <S:Body>
> <gwm:createCursorResponse
> xmlns:gwe="http://schemas.novell.com/2005/01/GroupWise/events"
> xmlns:gwm="http://schemas.novell.com/2005/01/GroupWise/methods"
> xmlns:gwt="http://schemas.novell.com/2005/01/GroupWise/types">
> <gwm:cursor>‑122826395</gwm:cursor>
> <gwm:status>
> <gwt:code>0</gwt:code>
> </gwm:status>
> </gwm:createCursorResponse>
> </S:Body>
> </S:Envelope>
> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
> <S:Body>
> <ns3:readCursorRequest
> xmlns="http://schemas.novell.com/2005/01/GroupWise/types"
> xmlns:ns2="http://schemas.novell.com/2005/01/GroupWise/events"
> xmlns:ns3="http://schemas.novell.com/2005/01/GroupWise/methods">
> <ns3:container>folders</ns3:container>
> <ns3:cursor>‑122826395</ns3:cursor>
> <ns3:forward>true</ns3:forward>
> <ns3:count>1000</ns3:count>
> </ns3:readCursorRequest>
> </S:Body>
> </S:Envelope>
> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
> <S:Header />
> <S:Body>
> <gwm:readCursorResponse
> xmlns:gwe="http://schemas.novell.com/2005/01/GroupWise/events"
> xmlns:gwm="http://schemas.novell.com/2005/01/GroupWise/methods"
> xmlns:gwt="http://schemas.novell.com/2005/01/GroupWise/types">
> <gwm:items>
> <gwt:item xmlns:xsi="http://www.w3.org/2001/XMLSchema‑instance"
> xsi:type="gwt:Mail">
>
>

<gwt:id>4C98CFA7.s1tv.fantasticpo.100.1757630.1.50D0.1@1:4A952666.s1tv.fanta
s
> ticpo.100.1757630.1.5070.1@13</gwt:id>
> <gwt:version>3</gwt:version>
> <gwt:modified>2010‑09‑21T13:30:56Z</gwt:modified>
>
><gwt:container>4A952666.s1tv.fantasticpo.100.1757630.1.5070.1@13</gwt:conta

ine
> r>
> <gwt:created>2010‑09‑17T12:29:55Z</gwt:created>
> <gwt:customs>
> <gwt:custom type="Numeric">
> <gwt:field>archived</gwt:field>
> <gwt:value>1</gwt:value>
> </gwt:custom>
> </gwt:customs>
> <gwt:status />
> <gwt:msgId>4C98CFA7.s1tv.fantasticpo.200.200007E.1.528.1</gwt:msgId>
> <gwt:source>received</gwt:source>
> <gwt:delivered>2010‑09‑17T12:29:55Z</gwt:delivered>
> <gwt:security>Normal</gwt:security>
> <gwt:subject>test</gwt:subject>
> <gwt:distribution>
> <gwt:from>
> <gwt:displayName>Wayne rooney</gwt:displayName>
> <gwt:email>wayne@fantastic.socs.lan</gwt:email>
> <gwt:uuid>59A83700‑1732‑0000‑8576‑D999178DF7D8</gwt:uuid>
> </gwt:from>
> <gwt:to>Alex ferguson</gwt:to>
> <gwt:recipients>
> <gwt:recipient>
> <gwt:displayName>Alex ferguson</gwt:displayName>
> <gwt:email>alex@fantastic.socs.lan</gwt:email>
> <gwt:uuid>92481080‑1732‑0000‑8576‑D999178DF7D8</gwt:uuid>
> <gwt:distType>TO</gwt:distType>
> <gwt:recipType>User</gwt:recipType>
> </gwt:recipient>
> </gwt:recipients>
> <gwt:sendoptions>
> <gwt:statusTracking>None</gwt:statusTracking>
> </gwt:sendoptions>
> </gwt:distribution>
> <gwt:message>
> <gwt:part contentType="text/plain"
>

length="160">e1xydGYxXGRlZmYwe1xmb250dGJse1xmMFxmbmlsXGZjaGFyc2V0MSBUYWhvbWE
7
>

fX17XHN0eWxlc2hlZXR7XGZzMTYgR3JvdXBXaXNlVmlldzt9fVxmczE2IGFzZGZhc2RmIHNhZGYg
Y
> XNkZiBzZCBhYSBkfQ==</gwt:part>
> </gwt:message>
> <gwt:attachments>
> <gwt:attachment>
>
>

<gwt:id>4C98CFA7.s1tv.fantasticpo.200.200007E.1.525.1@45:4C98CFA7.s1tv.fanta
s
>

ticpo.100.1757630.1.50D0.1@1:4A952666.s1tv.fantasticpo.100.1757630.1.5070.1@
1
> 3</gwt:id>
> <gwt:name>TEXT.htm</gwt:name>
> <gwt:contentType>TEXT/HTML</gwt:contentType>
> <gwt:size>237</gwt:size>
> <gwt:date>2010‑09‑17T14:29:49Z</gwt:date>
> <gwt:hidden>1</gwt:hidden>
> </gwt:attachment>
> <gwt:attachment>
>
>

<gwt:id>4C98CFA7.s1tv.fantasticpo.200.200007E.1.526.1@45:4C98CFA7.s1tv.fanta
s
>

ticpo.100.1757630.1.50D0.1@1:4A952666.s1tv.fantasticpo.100.1757630.1.5070.1@
1
> 3</gwt:id>
> <gwt:name>Water lilies.jpg</gwt:name>
> <gwt:contentType>image/jpeg</gwt:contentType>
> <gwt:size>83794</gwt:size>
> <gwt:date>2010‑09‑17T14:29:49Z</gwt:date>
> <gwt:hidden>0</gwt:hidden>
> </gwt:attachment>
> </gwt:attachments>
> <gwt:options>
> <gwt:priority>Standard</gwt:priority>
> </gwt:options>
> <gwt:hasAttachment>1</gwt:hasAttachment>
> <gwt:size>84918</gwt:size>
> </gwt:item>
> </gwm:items>
> <gwm:status>
> <gwt:code>0</gwt:code>
> </gwm:status>
> </gwm:readCursorResponse>
> </S:Body>
> </S:Envelope>
> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.