Listing appointments of a contact - odata

I'd like to list the appointments that a contacts is set to as a required participating party. I'm running the following query in my organization.
The service end point is set up like so.
https://bazinga/XRMServices/2011/OrganizationData.svc/AppointmentSet?
And then I concatenate that with the following.
$select=
ScheduledStart,
ModifiedOn,
appointment_activity_parties/PartyId
&$top=1000
&$filter=
ModifiedOn gt DateTime'2014-08-21'
&$expand=appointment_activity_parties
This gives me a list of a few appointments and when I investigate the contents, I can clearly see a tag called PartId with Id, Name etc. in it. The infromation is there. Then I check by hand the guid of the contact I'm curious about and add another condition in the filter specifying it.
$select=
ScheduledStart,
ModifiedOn,
appointment_activity_parties/PartyId
&$top=1000
&$filter=
(ModifiedOn gt DateTime'2014-08-21')
and (appointment_activity_parties/PartyId eq guid'...')
&$expand=appointment_activity_parties
However, the stupid organization service says that no property PartyId exists. When I try adding /Id, it says something about no support for complex data types when querying. I'm sure it's just a small syntax thingy but after a few hours and sick and tired. What do I miss?!

Your scenario behind the clause (appointment_activity_parties/PartyId eq guid'...') is that you want to find out appointments in the Appointmentset the PartyId of whose appointment_activity_parties equals a certain GUID. But you need to specify do you want to return the appointment if the PartyId of any of its appointment_activity_parties equals that GUID, or you want to return the appointment only when all of the PartyId of its appointment_activity_parties equals that GUID.
This any and all difference is specified in the section 5.1.1.2 of OData V4 Protocol part 2: URL Conventions.
Thus, you can rewrite your query as follows:
$select=
ScheduledStart,
ModifiedOn,
appointment_activity_parties/PartyId
&$top=1000
&$filter=
(ModifiedOn gt DateTime'2014-08-21')
and (appointment_activity_parties/any(a:a/PartyId eq guid'...'))
&$expand=appointment_activity_parties
And you can choose modify the any to all according to your actual needs.

Related

MS Graph: orderby=lastModifiedDateTime is failing

According to the DOCs is the lastModifiedDateTime should be a valid parameter for the orderby :
"Comma-separated list of properties that are used to sort the order of items in the response collection. Works for name, size, and lastModifiedDateTime fields."
however, this request is failing:
https://graph.microsoft.com/v1.0/me/drive/root/children?orderby=lastModifiedDateTime desc
is this a bug? as it's working with the name
According to your description, you want to list the children item order by the ‘lastModifiedDatetime’.
Base on my test, It’s most likely a bug or by design. We can posted it on Microsoft User Voice to let developer know.

Getting some data from Microsoft Graph unified OData endpoint

How to count number of items in EntitySet of MicrosoftGraph, for example 'users' or 'groups'? I tried:
https://graph.microsoft.com/v1.0/users?$count
Returns: lists all users
https://graph.microsoft.com/v1.0/users/$count
Returns:
{ "error": { "code": "Request_BadRequest", "message": "Unexpected segment Edm.Int32.", } }
Also in Annotations of target "microsoft.graph.directoryObject" which are those EntitySets based on I see that it is Selectable=false, Countable=false ...
Will $skip be ever available on 'users' or other toplevel EntitySet items ( https://graph.microsoft.com/v1.0/groups?$skip=5 ) ? It is available on other items ( https://graph.microsoft.com/v1.0/me/contacts?$skip=5 ). I know about $skipToken, but it is not the same.
Can I find somewhere in the $metadata if property is sortable? For example user.displayName is sortable, but user.mail or user.givenName are not. This would be handy in the $metadata. Is there plan to introduce this into $metadata?
OrderBy DESC in this formula https://graph.microsoft.com/v1.0/users?$orderBy=displayName%20desc is ignored, it shows items ordered ASC, am I doing something wrong?
Not much help I know, but if you do an API call that gets a Collection you can get a count using the second form you gave in the first question. Eg:
https://graph.microsoft.com/v1.0/users/<id>/events/$count
returns the count (6 in my case, and not in JSON - the returned data is actually "\x{ef}\x{bb}\x{bf}6" (in Perl formatting)). If we use the ? as the last separator (which is what http://graph.microsoft.io/en-us/docs/overview/query_parameters seems to indicate we should) with this URL:
https://graph.microsoft.com/v1.0/users/<id>/events?$count
I just get the list of events with no count as you do.
So that seems to indicate two things to me:
a) The $count doesn't appear to work as a query parameter, despite the documentation and the OData standards saying it should,
and
b) There seems to be a bug in the API for handling EntitySets which isn't there for Collections.
Sorry I can't be of more help, but its another data point at least (I just came unstuck with the same thing which is why I noticed this StackOverflow post!)
Ad 1. https://graph.microsoft.com/v1.0/users/$count is the correct OData syntax (http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398087), but as indicated in the metadata directoryObject collections are not currently countable. ODataV4 also allows $count in query parameters (http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398166), but then it should be specified with true or false value (e.g. https://graph.microsoft.com/v1.0/me/events?$count=true) and the response will include both the collection and its count in the #odata.count property. This is again not supported for directoryObject collections.
Ad 2. There is no plan right now to support $skip for directoryObject collections.
Ad 3. Yes, we plan to indicate which properties are sortable by in metadata using the SortRestrictions annotation defined in the OData capabilities vocabulary (http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/vocabularies/Org.OData.Capabilities.V1.xml)
Ad 4. Your request is correct, but we only support sorting users by displayName in the ascending order.

QBFC: How do I query the customners by accountnumber?

Since Intuit has broken the QBFC reference today, I have to ask a question that I could normally look up. (I do not know who to complain to).
I normally query by list_id like so:
ICustomerQuery CustomerQueryRq = requestMsgSet.AppendCustomerQueryRq();
CustomerQueryRq.ORCustomerListQuery.ListIDList.Add(qb_list_id);
Is there a way to query by AccountNumber?
Thanks!
No, QuickBooks does not support querying by the AccountNumber field.
This is old, but maybe worth adding.
Create a temp "cached" object, containing all the properties you want to search for. Them when launching, and whenever customer changes are made, cache a list of custom QBcustomersForSearch objects with only the properties that you would want to use for the search.
class qbCustomerForSearch
property email as string
property accountnumber as string
property whatever as string
property QBListId as string
end class
Cache / create a list of these objects when and as needed, and search your list. Once located in your list, use the listID to identify the QB customer.
Cheers

QBD Query Item by Name (DevKit)

How to query an item by name? I thought this might work the same as looking up a customer by name, but it seems like not.
For .net you can refer to the class library documentation here:
http://developer-static.intuit.com/SDKDocs/QBV2Doc/IntuitDataServicesSDK/
If you go to ItemQuery, you will se it exposes ItemElementName of return type ItemChoiceType4 enum.
If you go to the ItemChoiceType4 details, You will see it exposes, IteratorId and StartPage.
As mentioned above, Items cannot be queried by name.
Similarly for customer query on name, you can get details that it exposes Item1ElementName which returns Item1ChoiceType enum.
For all entities similarly you can search.
Using items will not be so elusive then. :)
Also, for each entity for QBD, you can reference the docs too and refer to Query Attributes section for details.
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/0600_object_reference
QBD Items can't be retrieved by name
Ref QueryFilter Docs -
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/0600_object_reference/item#Retrieving_Items_Using_a_Query_Filter

Grails GORM findAll returns null collection

Consider the following domain models:
class Sales{
String salesInvoice
Customer customer
}
class Customer{
int customerNumber
String name
}
The problem: I am trying to retrieve all the sales given a customer. Thus the code:
def sales = Sales.findAllByCustomer(Customer.get(params.id))
I don't have problem with getting the customer. But when I use println sales.dump() I get something like
<java.util.ArrayList#d3a25f8 elementData=[mypackage.Sales : null, mypackage.Sales : null] size=2 modCount=3>
If I understand correctly, this means that the query was able to get a list of Sales but what I don't quite understand is why is it returning a list of nulls? I've tried eager fetching but I don't think that will work in this particular problem. So how to I get a list of non-null Sales objects?
The objects you have shown are not NULL, but the id of the objects is currently NULL: Each grails domain object has a toString() method which will print ${name of the class} : ${id of the instance}. If you receive outputs, like you have shown, it generally means, that your instances are existing (otherwise a NPE would have been thrown!), however the id is not yet fetched from the DB.
I guess you are creating the objects in the code before. You need to flush the context, otherwise id's are not created.
You should declare, that your Sale belongs to a Customer. http://grails.org/doc/latest/guide/GORM.html#manyToOneAndOneToOne
BTW: Name you domain classes in singular. So rename Sales to Sale.

Resources