none
Unable to use & in RDO's SearchFolder.SearchCriteria.AsSQL RRS feed

  • Question

  • I am trying to set the SearchCriteria for a search folder by copying the one for "To-Do Search" and getting an error.

    Set nSession = CreateObject("Redemption.RDOSession")
    nSession.MAPIOBJECT = Application.session.MAPIOBJECT
    
    Set nStores = nSession.Stores
    Set nDefaultStore = nStores.defaultstore
    Set nSearchRootFolder = nDefaultStore.SearchRootFolder
    Set nFolders = nSearchRootFolder.Folders
    Set nToDoSearchFolder = nFolders.Item("To-Do Search")
    Set nTempSearchFolder = nFolders.Item("test")
    
    ' output of this is below
    Debug.Print nToDoSearchFolder.SearchCriteria.AsSQL
    
    ' output of this is below
    Debug.Print nTempSearchFolder.SearchCriteria.AsSQL
    
    ' try to set the test one to the todo one and it gets an error
    nTempSearchFolder.SearchCriteria.AsSQL = nToDoSearchFolder.SearchCriteria.AsSQL
    

    The SQL of the "To-Do Search" folder is:

    ((NOT (MessageClass LIKE 'IPM.Appointment%')) AND (NOT (MessageClass LIKE 'IPM.Activity%')) AND (NOT (MessageClass LIKE 'IPM.StickyNote%'))) AND ((("http://schemas.microsoft.com/mapi/proptag/0x0E090102" <> 'EF000000566DF349282A75418D7FCC22AD95C65562210000') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E090102" <> 'EF000000566DF349282A75418D7FCC22AD95C655E2830000') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E090102" <> 'EF000000566DF349282A75418D7FCC22AD95C655C2800000') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E090102" <> 'EF000000566DF349282A75418D7FCC22AD95C655A2210000') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E090102" <> 'EF000000566DF349282A75418D7FCC22AD95C65502850000') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E090102" <> 'EF000000566DF349282A75418D7FCC22AD95C65522850000') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E090102" <> 'EF000000566DF349282A75418D7FCC22AD95C655E2840000')) AND (((((NOT (FlagIcon IS NOT NULL)) OR (FlagIcon = '0')) AND (FlagStatus 
    IS NOT NULL) AND (FlagStatus = '1')) OR ((Status = '2') AND (Status IS NOT NULL))) OR (("http://schemas.microsoft.com/mapi/proptag/0x0E2B0003" IS NOT NULL) AND (("http://schemas.microsoft.com/mapi/proptag/0x0E2B0003" & 1) <> 0)) OR ((FlagIcon IS NOT NULL) AND (FlagIcon > '0')) OR ((NOT (("http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/8108000B" <> 'True') AND ("http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81130003" = '2'))) AND ((MessageClass LIKE 'IPM.Task.%') OR (MessageClass = 'IPM.Task')))))

    The error is:

    Run-time error '-2147418113 (8000ffff)':
    
    Assertion failed: Number of constants == 1

    I have narrowed it down to this:

    ("http://schemas.microsoft.com/mapi/proptag/0x0E2B0003" & 1) <> 0

    So I guess the question is how to do a binary AND using AsSQL?


    Friday, April 22, 2016 7:25 PM

Answers

All replies

  • When do you get that error? Are you resetting the AsSQL property?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, April 22, 2016 8:05 PM
  • In that very last line. I'm trying to set a search folder's SQL to match another search folders.

    I've narrowed it down to the bitwise AND.

    Friday, April 22, 2016 8:09 PM
  • Why do you need to use Redemption?

    Have you tried using the Outlook object model?


    [custom.development]

    Friday, April 22, 2016 8:20 PM
  • From what I can tell, the "To-Do Search" folder is not exposed through Outlook's object model.

    I want to copy it's SQL to another search folder.

    Friday, April 22, 2016 8:30 PM
  • I can make RDOSearchFolder.SearchCriteria property settable, so you won't have to deal with AsSQL...

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, April 22, 2016 8:36 PM
  • No need to do it for me. I was able to figure out how to do what I needed.

    Basically what I was trying to do is make it so the "To-Do Bar" only shows me flagged items in the current folder. So every time I change folders, the "To-Do Bar" should update.

    I was able to get that working.

    So now when I go to a folder, the "To-Do Bar" will only show me flagged items in that folder. 

    :) :) :)

    This makes me very happy. Hopefully it'll help me stay more organized.

    Friday, April 22, 2016 8:41 PM
  • Hi, IMTheNachoMan

    This is the forum to discuss questions and feedback for Outlook for Developers, since this issue is related to Outlook Redemption, I suggest that you could post your issue with FAQ on Outlook Redemption official site.

    Thanks for your understanding.
    Monday, April 25, 2016 6:08 AM