cancel
Showing results for 
Search instead for 
Did you mean: 

UI5 Combobox Key Issue

adnanmaqbool
Contributor
0 Kudos

Dear All

I have listed below the UI5 code, posting data to Odata. However, on saving it, the system is giving error, which means OData Property LO is receiving Text value of ComboBox.

Property 'LO' at offset '186' has invalid value 'Not Clear'

	<Label text="Legal Opinion" required="true" wrapping="true"/>
		<ComboBox id="lo_id" showSecondaryValues="true" 
		value="{path: 'LO'}" editable="true" enabled="true"
		width="50%" liveChange="_validateSaveEnablement" >
			<items>
			  <core:ListItem key="1" text="Clear"/>
			  <core:ListItem key="2" text="Not Clear"/>
			</items>
		</ComboBox><br>

Accepted Solutions (0)

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos
value="{path: 'LO'}"====>selectedKey="{path: 'LO'}"
adnanmaqbool
Contributor
0 Kudos

Do you Mean like below, it's also giving same error i.e. Text is passing to Odata instead of key while saving Form

		<ComboBox id="lo_id" showSecondaryValues="true" 
		selectedKey="{path: 'LO'}" editable="true" enabled="true"
		width="50%" liveChange="_validateSaveEnablement" >
			<items>
			  <core:ListItem key="1" text="Clear"/>
			  <core:ListItem key="2" text="Not Clear"/>
			</items>
		</ComboBox
junwu
Active Contributor
0 Kudos

are you saying

"Clear" this  text is passed to backend?

show me your coding, how you call backend? hopefully you are not trying to get value from control, which is very bad practice.

what you expect? your backend expect integer 1 or string 1 ?

adnanmaqbool
Contributor
0 Kudos

Yes "Clear" is passing to backend system where the property 'LO' is 1 character.

onSave: function() {
	var that = this,
	oView = this.getView(),
	oModel = this.getModel(),
	spath = oView.getBindingContext().getPath();
		/********** Updating Odata MOdel ******************/

				// abort if the  model has not been changed
				if (!oModel.hasPendingChanges()) {
					MessageBox.information(
						this._oResourceBundle.getText("noChangesMessage"), {
							id: "noChangesInfoMessageBox",
							styleClass: that.getOwnerComponent().getContentDensityClass()
						}
					);
					return;
				}
				this.getModel("appView").setProperty("/busy", true);
				if (this._oViewModel.getProperty("/mode") === "edit") {
					// attach to the request completed event of the batch
					oModel.attachEventOnce("batchRequestCompleted", function(oEvent) {
						if (that._checkIfBatchRequestSucceeded(oEvent)) {
							that._fnUpdateSuccess();
						} else {
							that._fnEntityCreationFailed();
							MessageBox.error(that._oResourceBundle.getText("updateError"));
						}
					});
				}
				// this.handleUploadPress();

				oModel.submitChanges();
			}
		},