cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Update fields

0 Likes
1,684

Hello,

I am trying to modify the field "leagueuuid" which is an external key, here is what my table looks like :

Here is my code in my xml View :

 <Input id="idlicence" width="27%"></Input>
 <ComboBox id="_IDMultiComboBox4-3" change="GetPersonalInformation" editable="true" items="{/ZC_KEL_TRI_LIGUE_F02}" enabled="true" width="242px" valueState="None" maxWidth="100%"> 
        <items>
            <core:Item id="_IDItem4-3-1" text="{LigueName}" enabled="true" key="{LigueId}"/> 
        </items> 
</ComboBox> 

Here is my code in my controller :

( I was inspired by this blog to implement the following function CRUD operations on Employee profile using SAP UI5 | SAP Blogs )

handleWizardSubmit: function () { 
var LicenceId = this.byId("idlicence").getValue(); 
var League    = this.byId("_IDMultiComboBox4-3").getSelectedKey(); 
      this.getOwnerComponent().getModel().read("/Licence", { 
            success: function (oData, oResponse) { 
                for (var i = 0; i < oData.results.length; i++) { 
                   if ( oData.results[i].LicenceId === LicenceId ) { 
                       var LicenceUuidFront = oData.results[i].LicenceUuid 
                       var payLoad = { "Leagueuuid": League, }; 
                           this.getOwnerComponent().getModel().update("/Licence('" + LicenceUuidFront + "')", 
                               payLoad, { method: "PUT", 
                               success: function (odata, Response) { 
                                   if (odata !== "" || odata !== undefined) { 
                                      MessageToast.show("Upadte successful"); 
                                    } else { 
                                      MessageToast.show("Update unsuccessful"); } 
                               }, error: function (xhr, ajaxOptions, thrownError) { 
                                     alert(xhr.responseText); }   
                               }); } } 
                        }.bind(this),
                 error: function (xhr, ajaxOptions, thrownError) { 
                      alert(xhr.responseText); 
        }.bind(this) }); },

Here is what my Metadata file looks like :

I don't know where the problem comes from or how to solve it.

View Entire Topic
junwu
SAP Champion
SAP Champion
LicenceUuid1  I don't see this variable is defined in your code.
0 Likes

Sorry it was just a typo it's LicenceUuid

junwu
SAP Champion
SAP Champion

I don't think you can change key of an entity if I am not wrong.

0 Likes

In fact "leagueuuid" is not a key, I know the name is confusing but its not, my key is "licenceuuid".

0 Likes

I just edited my post with more details, can you please take a look ?

junwu
SAP Champion
SAP Champion
0 Likes

in browser developer tool, show us the payload of your request