cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing OData values in controller extension "Failed to drill-down into" "Iinvalid segment:"

0 Kudos

Hello,

I am currently attempting to access data from an oData V4 service. The oData service is from a Service Binding connected to a Fiori elements app. In a controller extension, I have the following code which shows the various ways I have attempted to retrieve a list through first following an association to parent called "_email_temp" followed by an association to the actual list "_attributes":

var oContextBinding = this.getBindingContext();
var oModel = this.getModel();
var oList = oModel.bindContext("/_email_temp/_attributes");
oList.requestObject("").then(function (oObject) {
console.log(oObject);
});

oContextBinding.requestObject("_email_temp/_attributes").then(
function (oAttributes) {
console.log(oAttributes);
});
console.log(oContextBinding);

The issue is that this code fails with following the error:

2023-02-08 16:52:58.963000 Failed to drill-down into _email_temp/_attributes, invalid segment: _email_temp
- /sap/opu/odata4/ope/ui_pcc_et/srvd/ope/ui_pcc_email_template/0001/xOPExP_PCC_EMAIL_TEMP(EtUuid=02120fa4-97ee-1eed-a69e-3c2d1a7060fa,IsActiveEntity=true)/_translations(EmailTransUuid=02120fa4-97ee-1eed-a69e-3c2d1a70a0fa,IsActiveEntity=true)?$select=Description,EmailSendTypeDescription,EmailTransUuid,HasActiveEntity,HasDraftEntity,IsActiveEntity,Language,LanguageName,Status,StatusDesc,TemplateName,__EntityControl/Deletable,__EntityControl/Updatable sap.ui.model.odata.v4.lib._Cache

This is strange because the same error appears when simply trying to get the object "_email_temp" while getting a property from "_email_temp" works correctly. Is there any way to get these objects?

View Entire Topic
marcel_waechter
Advisor
Advisor
0 Kudos

Hi,

if you want to read data from a collection you need to use a list binding.

Here you can find a nice documentation on how to use the v4 model to request collections:

https://sapui5.hana.ondemand.com/#/topic/17b30ac2d5474078be31e695e97450cc

You'll find the following example on this page:

var oList = oModel.bindList("/SalesOrderList");

oList.requestContexts(
oList.requestContexts(10, 20).then(function (aContexts) {
    aContexts.forEach(
aContexts.forEach(function (oContext) {
// As we have fetched the data already, we can access "Note" through getProperty
var sNote = oContext.getProperty("Note");
if (!sNote) { oContext.setProperty(
oContext.setProperty("Note", "No notes"); } }); });
}
});
});

Best regards,
Marcel