Exchange EWS - How to retrieve occurrence from master event on specific date? - exchangewebservices

I want to retrieve the occurrence (ItemID) from a recurring master calendar event on a specific date (I have the date of the occurrence and the recurring master event data).
I was trying FindItem with a restriction like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
<typ:RequestServerVersion Version="Exchange2007_SP1"/>
</soapenv:Header>
<soapenv:Body>
<mes:FindItem Traversal="Shallow">
<mes:ItemShape>
<typ:BaseShape>AllProperties</typ:BaseShape>
</mes:ItemShape>
<mes:Restriction>
<typ:IsEqualTo>
<typ:FieldURI FieldURI="item:RecurringMasterItemId"/>
<typ:FieldURIOrConstant>
<typ:Constant Value="AQMkAD[snip]AAAAA=="/>
</typ:FieldURIOrConstant>
</typ:IsEqualTo>
</mes:Restriction>
<mes:ParentFolderIds>
<typ:DistinguishedFolderId Id="calendar"/>
</mes:ParentFolderIds>
</mes:FindItem>
</soapenv:Body>
</soapenv:Envelope>
but this returns:
The 'FieldURI' attribute is invalid - The value 'item:RecurringMasterItemId' is invalid according to its datatype (types:UnindexedFieldURIType) - The Enumeration constraint failed.
(I also know the ChangeKey for the recurring appointment and tried that, with the same error)
How should this be fixed to make it work?
BTW. I know about retrieving occurrences with GetItem like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
<typ:RequestServerVersion Version="Exchange2007_SP1"/>
</soapenv:Header>
<soapenv:Body>
<mes:GetItem>
<mes:ItemShape>
<typ:BaseShape>IdOnly</typ:BaseShape>
</mes:ItemShape>
<mes:ItemIds>
<typ:OccurrenceItemId RecurringMasterId="AQMkAD[snip]AAAA==" InstanceIndex="1"/>
<typ:OccurrenceItemId RecurringMasterId="AQMkAD[snip]AAAA==" InstanceIndex="2"/>
<typ:OccurrenceItemId RecurringMasterId="AQMkAD[snip]AAAA==" InstanceIndex="3"/>
</mes:ItemIds>
</mes:GetItem>
</soapenv:Body>
</soapenv:Envelope>
Then, I could retrieve StartDate and loop through them, but there is no way I can predict the InstanceIndex range that might apply.
Thanks in advance,
Jan

It does not look like this is possible.
I have now resorted to using GetItem, retrieving 50 occurrences at a time.
This returns a list of GetItemResponseMessages containing either:
Succesful occurrence retrievals
ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange responsecode indicating that we have reached the last occurrence
Other 'real' errors
ErrorCalendarOccurrenceIsDeletedFromRecurrence responsecode indicating that the occurrence was deleted
So I just loop until I have found the proper date, reached ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange, or reached a maximum number of calls set in my code.

Related

Verify vouchers integrated into tally from staging table

If I have 5 vouchers in SQL server database staging table and I imported all 5 vouchers in tally using tally XML API.
How can I verify and cross check the vouchers between tally and SQL using only voucher number?
Do I have to read entire voucher summary from tally and then extract voucher numbers from the XML data ? After extracting voucher numbers I can compare it to staging table.
How can I just export only voucher number or one specific field from a report in tally ?
Do you know the voucher number after importing into Tally? Depending on the answer to this, I'll update my answer.
Case 1: If you do know the voucher number, you can use Tally XML to request for that particular voucher number and if you get a positive response, then that voucher exists in tally. No need to read voucher summary. You'll just need to look for a particular element tag in XML response - if that element exists = voucher exists.
Case 2: But I assume you don't know the voucher number that was created during the import. In that case. It'll be a bit more tricky. Let me know and I'll update with whatever solution I have.
--Update--
After discussing (see comments), I'm updating the answer as per Case 1.
XML Request Structure -
<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>EXPORT</TALLYREQUEST>
<TYPE>COLLECTION</TYPE>
<ID>FindParticularVoucher</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
<SVCURRENTCOMPANY>FOO COMPANY</SVCURRENTCOMPANY>
<VCHNO>ABC1234</VCHNO>
</STATICVARIABLES>
<TDL>
<TDLMESSAGE>
<COLLECTION NAME="FindParticularVoucher" ISINITIALIZE="YES">
<TYPE>Voucher</TYPE>
<FILTER>GetInvoiceVoucher</FILTER>
</COLLECTION>
<VARIABLE NAME="VCHNO">
<TYPE>String</TYPE>
</VARIABLE>
<SYSTEM TYPE="FORMULAE" NAME="GetInvoiceVoucher">$VoucherNumber = $$String:##VCHNO</SYSTEM>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>
</ENVELOPE>
Remember to change the Company name & Voucher Number within the SVCURRENTCOMPANY and VCHNO Xml Tags.
You might get a complex XML Response. All you need to do is look for the XML Node named Voucher within the Collection Node - Envelope/Body/Data/Collection/Voucher. If this VoucherNode exists = your voucher exists in tally. In this case you don't need to export any data or the voucher number.
When you create a voucher using XML in Tally, you would get a XML response on successful creation. That response has a tag for, among other things, the voucher number that you have given, and a LASTVCHID. This is like the master ID in tally. It's then easier to just request that master id and check the response. It would give an error if it doesn't find that master id (best of all, the error is just a one line XML response so no parsing required).
Check out this stackoverflow link for more details - how to filter tally xml response based on voucher number?

XPages JSON service not returning all records when using search

I am display data in a fullcalendar via a JSON service (calling a Lotus Notes database). If I do a simple call, all the data is returned - which is good but there are over 3000 documents, so this slows the calendar response. When I try and reduce the number of records being returned via a search such as
" FIELD EV_StartTime >= 01-10-2018 AND FIELD EV_EndTime <= 01-06-2019";
or
" FIELD EV_Category = Watches "
then only 33 records are returned (1095 expected)
I have the count field set to 1000 as suggested by others but this has made no difference (tho it does when I have no search criteria).
Thanks for any suggestions!
In case anyone else has a this issue, in the Rest Service control there is a property called searchMaxDocs which requires a value, when doing a search, otherwise it appears to default to a smallish value

Exchange EWS ID conversion

I am trying to build an EWS (via SOAP - it's a PHP app, no .net!) application that looks up the appointments of an arbitrary user and then looks up, if possible, the appointment details.
I use the GetUserAvailability call and get CalendarEvents back from it. So far so good, for events where I have view permission in Outlook too I get a CalendarEventDetails block inside the CalendarEvent. The ID however is nothing I can use in a subsequent GetItem call:
ID from CalendarEventDetails: 00000000D18EFE3E27D8FA498176E18417AF9E590700B2A9C65B63B7D74B9028423C9EEB4F6800000000010D0000B2A9C65B63B7D74B9028423C9EEB4F6800008765890B0000
ID from the CalendarItem retrieved by a FindItem call (on the Calendar folder of the target user): AAMkAGM5ODcxMzhjLTRkMGYtNDVmNC1iOTc5LTMyNWIyZTJhNWVjZABGAAAAAADRjv4+J9j6SYF24YQXr55ZBwCyqcZbY7fXS5AoQjye609oAAAAAAENAACyqcZbY7fXS5AoQjye609oAACHZYkLAAA=
When I base64-decrypt the FindItem ID and convert it to hex, the FindItem id seems to consist of some header, a UUID and the ID from CalendarEventDetails.
What do I need to do to use a CalendarEventDetails ID with a GetItem call?
00000000D18EFE3E27D8FA498176E18417AF9E590700B2A9C65B63B7D74B9028423C9EEB4F6800000000010D0000B2A9C65B63B7D74B9028423C9EEB4F6800008765890B0000
This Id is the HexEntryId of the calendar appointment so it needs to be converted to an EWSId using the ConvertId operation in EWS https://msdn.microsoft.com/en-us/library/office/bb799665(v=exchg.150).aspx . You will need to convert from Type HexEntryId to EWSid eg
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:ConvertId DestinationFormat="EwsId">
<m:SourceIds>
<t:AlternateId Format="HexEntryId" Id="00000000D18EFE3E27D8FA498176E18417AF9E590700B2A9C65B63B7D74B9028423C9EEB4F6800000000010D0000B2A9C65B63B7D74B9028423C9EEB4F6800008765890B0000" Mailbox="user#domain.com" />
</m:SourceIds>
</m:ConvertId>
</soap:Body>
</soap:Envelope>

Odata query for outlook rest api

How to use search and filter in the same query?
String url = "https://outlook.office.com/api/v2.0/me/messages?$filter=ReceivedDateTime ge 2016-02-22&$select=Subject,From,Body,ReceivedDateTime&$search=\"subject:(Chris Brown OR Michael Jackson)\"";
I need to find all mails with Subject having either "Chris Brown" or "Michael Jackson" and mail received date after 22nd Feb, 2016. Also it should have Subject, From, Body, ReceivedDateTime in the REST response.
Could anyone please help?
FYI - I am getting output if it has either filter or search. But when given together, I am getting a "Bad Request" error.
Right now this is not supported. From Use OData query parameters:
You cannot use $filter or $orderby in a search request.
So, the only way to do this is to perform a search via a query, and then filter on the client; or vice versa.
Update
In this particular case, since subject is filtrable and supposedly you only need an exact subject match (and not 'contains' for example), you can use something along the lines of:
https://outlook.office.com/api/v2.0/me/messages?$filter=(ReceivedDateTime ge 2016-02-22) and ((subject eq 'Chris Brown') or (subject eq 'Michael Jackson'))
To answer the original question: yes it is possible. #roman-pletnev correctly pointed out that you cannot use $filter or $orderby in a $search request. However, you can achieve the desired result using just $search.
$search="
(subject:(Chris Brown) OR subject:(Michael Jackson))
AND (received:02/22/2016..10/21/2016)
"
Note that extra linebreaks have been included for readability.
Also note that the received parameter seems to only work with a single date, or a specific range. I.e. you cannot request "everything after 02/22/2016". Instead you have to input today's date (or a future date?) as the end of the range.
received:<date>
received:02/22/2016
received:<start>..<end>
received:02/22/2016..10/21/2016
I'm not 100% sure about the date format. I don't know if it's determined by your account's locale or if it's always MM/DD/YYYY.
Other variations seem to work as well. However, the documentation for this is very bad and most of the documented syntax for "received" doesn't seem to work. I've filed a support ticket with Microsoft regarding this.
Some other documented syntax does work, for example received:today
Some documented syntax does not work, for example received:October
References:
https://support.office.com/en-us/article/Learn-to-narrow-your-search-criteria-for-better-searches-in-Outlook-d824d1e9-a255-4c8a-8553-276fb895a8da
https://support.office.com/en-us/article/Search-Mail-and-People-in-Outlook-on-the-web-for-business-88108edf-028e-4306-b87e-7400bbb40aa7
https://msonlinehelpdesk.zendesk.com/hc/en-us/articles/200561417-Learn-how-to-fine-tune-email-search-results-in-Outlook-and-Outlook-Web-App-OWA-

Couchbase document dates search - DateTime.Now()

I have a document in CB which has two dates, a start date and an end date. Let's say, a product's price discount. 10% off starting from today and ends next Friday. How can I get all the documents from CB which have a valid discount today?
I made a view and have the following in it:
var dt = new Date();
Which gets today's date. Then I can do a simple
if(doc.FromDate < dt && doc.ToDate > dt){ emit([ ..... ]);
This filters the documents how I want. But...
Question
Is this a good approach re view and index updating? Will the index update every day because the date changed? Just trying to understand the working of CB in this respect
What is the best approach for this type of searching? If not possible please tell me!
Cheers
Robin
Note: Please note, the question is NOT like this here or this here
Let's me clarify something here:
the map() function is used to create/update the index on disk, and this occurs just "after" the document is saved on disk. This is why using date.now() in the map reduce does not really makes sense.
So what you will do is to emit the date for example emit( dateToArray(doc.startDate) );
then when you query the view(index) you can use the startkey & endkey to do a range query.
&startkey=[2013,4,16]&endkey=[2013,4,24]
the index won't be updated just because system date changed, you have to update the document. also view indexer doesn't allow you to pass any arguments defined by user. in this case you should emit the data and use date as a part of the key to filter on view query. I guess the same behaviour for SQL indexes too. you cannot predict when exactly this document will indexed, in your example you are freezing timestamp when the doc has been indexed, it isn't even the time when it was changed