ADF - Odata - How to perform an optional select - odata

I've created an ADF flow that loops over URL's to fetch OData using the OData connection.
However, not all fields are available in all URL's, there are certain ones that are available in one URL, but not in the other. A $Select is used to select the fields that we need.
Is it possible to have an optional selection (as in, if the path is not available, do not fetch this field and return null instead for instance)? Would help us a great deal.
I've tried adding ? after the field, but that does not work. $select=Field1,Field2,FieldOptional?
Thanks

As I understand you are trying to loop through a bunch of a URL and the query on the ODATA URL will change and so will be the fields . I think you can use a lookup where you pass the unique url and its gives the fields and then concatenate the url with the fields and make a odata call .

Related

Applying $filter option to GetRecentFiles call in MS Graph API

I'm using getRecentFiles MS Graph API and I'd like to filter out only certain file types (by file extension). However, when I try $filter query parameter it is ignored. Documentation on the method doesn't mention anything like this.
Is this behavior expected or is it a bug?
I believe that is expected as no OData query parameters link is not present on the page (when OData query parameters are supported, then its listed in a paragraph).
I have not managed to make it work, neither for drive item properties (eg. id, creation date) nor for nested properties (remoteItem/name or remoteItem/createdBy/user).

Possible to select a specific entity without knowing the key in OData?

I have a problem where I need to select a specific value from a specific entity from a entity set, however, I need to do it in a way without knowing the key.
This is the query I actually need:
odata/..../picklistLabels(locale='en_GB',optionId=10819)/label
However I need to program it in a way so it automatically selects the label without knowing the optionId. Is there a way to do this in OData?
From your question, I think that you want to perform a navigation but you don't have a key. Unfortunately, this exact functionality isn't available, however, you can perform an expand like this:
odata/..../picklistLabels?$filter=locale eq 'en_GB' and optionId=10819&$expand=label
This will get you the same information that the other call would do but in a slightly different format, you would have to find the first element in the array and then get the label property to get that information
As an aside, if you have the option to change the server (I'm guessing not due to the sapui5 tag but it might be useful for other users) you could change the key. If the locale and the optionId are enough to identify the object, then you could make these into a composite key. Here is a link for an example within the WebAPI OData source code: https://github.com/OData/ODataSamples/tree/master/WebApi/v4/ODataCompositeKeySample

Sorting OData model in SAPUI5

Dear SAPUI5 Developers,
I developed a SAPUI5 Fiori Worklist project by using WebIDE template projects.
In the Component.js file the OData model has been fetched.
var sServiceUrl = this.getMetadata().getManifestEntry("sap.app").dataSources.mainService.uri;
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, {
json: true,
loadMetadataAsync: true
});
oModel.attachMetadataFailed(function() {
// Call some functions from APP controller to show suitable message
}, this);
this.setModel(oModel, "BrandSet");
This part of code causes a call to OData server to fetch data from the remote server.
Now I want to order the data in backend and then receive the data. Assume the sorting function has been implemented correctly in the backend.
Thus, if I use $orderby=name or $orderby=price it has to be sorted by name or price respectively.
In some toturial they said for ordering use sorter option inside of the XML view file. Like here:
https://sapui5.hana.ondemand.com/#docs/guide/c4b2a32bb72f483faa173e890e48d812.html
Now my questions are:
How to apply this sorting inside of the Component.js file where the Model is initiated?
The second question is how to apply this ordering when we apply a filter to the model? Like the example that in the following link applied filter:
https://sapui5.hana.ondemand.com/#docs/guide/5295470d7eee46c1898ee46c1b9ad763.html
In fact I am looking for a function or any kind of method that add the $orderby=xxx to the OData service call.
I found a way here: https://sapui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.odata.ODataModel.html#constructor
If I use mParameters.serviceUrlParams then I can add some URL parameter to the service request but it has been said "these parameters will be attached to all requests". Does it mean if I add the $orderbywith this method then I can not get rid of that in the further requests on that data model for example for filtering?
An app would normally be structured a bit differently to what you propose. The general assumption is that there is a lot of data available from the backend and to load all this data at once can cause performance problems, particularly when used over a mobile phone network. Furthermore, the data is an oData Entity Set, that is, a list of many items of the same type, so the data would be presented in the UI with a list or table.
Typically the app would then show the data in some kind of list, such as sap.m.List or sap.m.Table. These controls are designed to work with large volumes of data and would load initially the first 20 items from the entity set. Only when the user scrolls down the list of data would additional items be loaded. Also, with these controls the user can decide to sort or filter the data according to certain fields in your data.
Assuming that your app is work like this, here is the standard approach.
The Main model (as defined in the manifest) would not be loaded in Component.js, but loaded via the binding defined in the xml views of the app. In the views you could define a fixed sort and/or filter in the binding or you could allow the user to set the sort and filter criteria. This would be handled programmatically in the respective controllers. Normally the changes that the user makes to the sort and filter would be applied separately. For example, he/she chooses an new sort order, the oData is reread and the new sort order shown in the UI. Then the user may chose a filter criteria, and this is applied too. Of course, in your programming logic in the controllers you would need to have applied any default sort and filter criteria and then maybe combine or replace these with the criteria selected by the user.
To see an example of this, I would suggest to look at the Template Application “SAP Fiori Master-Detail Application” in the WebIDE.

OData Delete with Filter

I have the problem that our backend uses an OData-"like"-Processor which has some special functions. It is oriented at OData_2.0
So the question will be:
What is the most OData like approach for this kind of the following requests
Our backend Data-Model has no single-attribute-keys. But it's recommended to be OData-Like if possible.
First: I need to delete several objects via one OData Request. My first idea is to use filters to define which objects should be deleted. But I', not sure if this is the right approach.
For Example: I want to delete all Items which have a price greater than 10.00
http://.../<oDataServiceX>/Item?$filter=ItemPrice gt 10.00
Second: When I want to delete an object which is not identifiable by one single key-attribute. How can I define that in the classical OData-Delete-Request-Syntax.
Is the following OData-like?
http://.../<oDataServiceX>/Item(1,54,2) //3 Attributes which define the key for the Item
Or should I do a filter again? (If filter is a proper way of doing this).
http://.../<oDataServiceX>/Item?$filter=keyAttr1 eq 1 and keyAttr2 eq 54 and keyAttr 3 eq 2
You can't delete multiple entries in a single OData query, you need first to retrieve their keys and then send multiple delete requests. There are two ways to improve this process:
Use OData batch to send all delete request in a single HTTP call.
Use some of libraries that can simulate deletion using filter (internally they will issue multiple requests but for the application it will look like a single call). One of such libraries is Simple.OData.Client.
Hope this helps.
Odata v4 supports the format DELETE /entity(key1='', key2='') and so on.
However, for oData v2, one option could be to use the request body to pass some data over. DELETE /entity, with data in the body.
The documentation states that the convention is to delete an entity by key. However, this was the approach followed when we had to delete by multiple keys for an odata v2 service. Also while implementing this using oData v2 libraries, we had to add a routing convention to support Delete without a key.

APIs not returning custom field

for our scopes we need to use unique ID generated by us for the answers submitted by users. This is possible by adding "?c=" at the end of the survey link followed by the ID number.
Example Format: http://www.surveymonkey.com/s/XXXXX?c=00001
The terrific problem is that the custom value is not returned anyway via API. It is not added as a property of the Answer object neither its value replaces somehow the respondant_id property.
We see that you are able to expose that data from your internal endpoints that you use for your proprietary web interface but how to get this data from he outside via API?
Thanks
When you call 'get_respondent_list', ensure you pass through 'custom_id' in the list of strings in the 'fields' parameter. This will then be returned in the output with the custom value you entered.

Resources