Skip to Content
-2
Jun 08, 2020 at 08:41 AM

SAPUI5 code help

40 Views

Hi team,

Kindly help me with the below code. I have a function "saveobservation" which goes provides the correct data once clicked on send button, but when the send button is clicked twice it goes in code loop twice and data gets manipulated. Here we need to send the data to backend as same and avoid manipulation of data.

code-help.txt

1st-call.png

2nd-call.png

  • First Send Call: Original data that is saved in view model for Conducted by has the format, means an ANumber and FullName.
  • In the function call at step 2, it manipulated the object and changes it FullName and Id (as below) and deletes the ANumber element from object
  • But it still goes well in the first call as it is copying from ANumber and value in ANumber exists. After first call fails and user hits send again, it again goes to same loop and tries to assign ANumber to Id, but this time ANumber does not exist anymore and the only elements in object are Id and FullName
  • That’s where it makes id undefined and it does not get added to the call for saving
  • Solution: Enhance code in this loop to not to manipulate original object and play with some local variable to shuffle values

Attachments

1st-call.png (171.7 kB)
1st-call.png (171.7 kB)
2nd-call.png (161.1 kB)
2nd-call.png (161.1 kB)
1st-call.png (171.7 kB)
code-help.txt (817 B)