03-05-2024 8:07 PM - edited 03-05-2024 8:38 PM
Hello everyone,
I'm new to oData v4 and I'm starting to use it in a SAPUI5 project after implementing CAP with a Postgres DB.
Currently, the scenario is as follows: Entity Template has multiple TemplateFields.
I have several questions regarding this:
...
<EntityType Name="Template">
<Key>
<PropertyRef Name="Template_ID"/>
</Key>
<Property Name="createdAt" Type="Edm.DateTimeOffset" Precision="7"/>
<Property Name="createdBy" Type="Edm.String" MaxLength="255"/>
<Property Name="modifiedAt" Type="Edm.DateTimeOffset" Precision="7"/>
<Property Name="modifiedBy" Type="Edm.String" MaxLength="255"/>
<Property Name="Template_ID" Type="Edm.String" Nullable="false"/>
<Property Name="Description" Type="Edm.String"/>
<NavigationProperty Name="Fields" Type="Collection(LaborTrackingService.TemplateFields)"/>
</EntityType>
<EntityType Name="TemplateFields">
<Key>
<PropertyRef Name="Element"/>
<PropertyRef Name="Status"/>
<PropertyRef Name="Template_ID"/>
</Key>
<Property Name="Element" Type="Edm.String" Nullable="false"/>
<Property Name="Status" Type="Edm.String" Nullable="false"/>
<Property Name="Template_ID" Type="Edm.String" Nullable="false"/>
<NavigationProperty Name="Template" Type="LaborTrackingService.Template">
<ReferentialConstraint Property="Template_ID" ReferencedProperty="Template_ID"/>
</NavigationProperty>
<Property Name="Visible" Type="Edm.Boolean"/>
<Property Name="Editable" Type="Edm.Boolean"/>
<Property Name="Mandatory" Type="Edm.Boolean"/>
</EntityType>
...
<m:Button id="idBtnSave2" text="{i18n>btnSave}" visible="{path: '/TemplateFields(Template_ID=\'TEMPGEN\',Element=\'Comment\',Status=\'INITIAL\')/Visible', type: 'sap.ui.model.odata.type.Boolean'}" />
2- I attempted to select all the TemplateFields and then manipulate the result with either the event data receiver or the formatter. However, it did not work as expected.
<m:TextArea id="idComment" visible="{path : '/TemplateFields', events : { dataRequested : '.onDataReceived' }, formatter:'.setVisibility' }" />
Error:
2024-03-05 14:47:34.099000 FormatException in property 'visible' of 'Element sap.m.TextArea#application-labor_traking-edit-component---MainView--idComment': Type 'sap.ui.model.odata.type.Raw' does not support formatting
3 - If I attempt to retrieve data directly from the CDS using the parameters provided in the documentation, I encounter errors:
Uncaught (in promise) Error: System query option $select is not supportedIn my example, I aim to select the Visibility of the first element by filtering for predefined data (in any case, we face the issue mentioned in point 1).
<m:Input id="idTest1" visible="{path : '/TemplateFields', parameters : { $select: 'Visible', $top : 1, $filter : 'Template_ID eq \'TEMPGEN\''}, events : { dataRequested : '.onDataReceived' } }" />
4 - If I resort to using the controller and JavaScript, I must bind field by field correctly. Do you believe there is a possible solution to this, with the controller?
To conclude those are the data:
Thank you,
Sebastiano
I decide to use simple ajax call and anti-pattern JSON Model because I have no time to study and implement another solution.
Here a blog could be useful:
https://community.sap.com/t5/technology-blogs-by-sap/implementing-crud-operations-in-odata-v4/ba-p/1...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.