cancel
Showing results for 
Search instead for 
Did you mean: 

How to update an entity with OData V4 in a custom page/form

renejurmann
Participant
0 Kudos

Hi experts,

I have created a custom page where the user can create a new entity using a deep insert. (see attached files for "NewScenario...")

The process should now be following:

  • The user enters the details for a new scenario
  • Once he clicks save, the scenario should be created using an OData V4 service (POST request)
  • As soon as the scenario is created the view should load the scenario from the OData V4 service and bind the attributes to the form fields
  • When the user now changes some values and saves those an update should be triggered via the OData V4 interface (PUT request)

The first two steps are working but the other two are not.

I know that I could trigger an AJAX call manually for the PUT request. But actually I want to use the implemented methods.

What I tried so far:

  • Doing all in one controller
    As soon as the new scenario is created I bind the view with the created entity. Additionally I execute a property binding of the according form fields.
  • Splitting creation and edit in two different controllers and views
    As soon as the new scenario is created I navigate to a specific edit view handing over the ID of the new sceanrio. The new view is then bound to the entity instance and all form fields have an according property binding.

But unimportant what I do, I get following error:

Failed to read path /name - TypeError: Cannot read properties of undefined (reading 'split')

Can you guide what is wrong or what I need to change?

regards

René

View Entire Topic
AnuradhaDhingan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi René,

Error "Cannot read properties of undefined (reading 'split')" occurs when 'split' method is called on a variable storing an 'undefined' value.

Solution:

We should ensure that we only call the 'split' method on strings; check if the variable is a string before calling 'split'.

typeof operator can be used to check if variable stores a string(before calling 'split').

renejurmann
Participant
0 Kudos

Hi Anurdha,

I do not call the split method by myself. This is called by some standard SAP logic as soon as a property binding is done. So, I can't check if the variable is a string...

Here a screenshot of the error message: