Показать сообщение отдельно
Старый 20.04.2017, 21:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
goshoom: OData service across companies
Источник: http://dev.goshoom.net/en/2017/04/od...oss-companies/
==============

The OData service in Dynamics 365 for Operations returns data from user’s default company. But you can easily add cross-company=true to the URL (e.g. https://myaos.cloudax.dynamics.com/d...s-company=true) to get data from all companies. You can also filter the query by DataAreaId field, if you want data from a specific company.

But developers usually don’t construct the URL by themselves; they use some libraries that deal with such implementation details. In .NET, you’ll most likely use OData Client Code Generator (which was also used to create the OData app in Microsoft’s integration samples). The obvious question is how to put the cross-company parameter there.

You can subscribe to the BuildingRequest event, parse the URL and add the parameter, like this:

context.BuildingRequest += (sender, e) =>{ var uriBuilder = new UriBuilder(e.RequestUri); // Requires a reference to System.Web var paramValues = HttpUtility.ParseQueryString(uriBuilder.Query); paramValues.Add("cross-company", "true"); uriBuilder.Query = paramValues.ToString(); e.RequestUri = uriBuilder.Uri;};






Note that simply attaching ?cross-company=true wouldn’t be enough; it wouldn’t work if there were some other parameters (such as for filtering).



Источник: http://dev.goshoom.net/en/2017/04/od...oss-companies/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.