Skip to Content

The hunt for the missing dialog value ^^

Helloooo experts,

I have a dialog which I use both for creating and updating entries. Everything works fine, except a tiny (but still annoying) bit.

When I call the dialog for an existing entry, everything is smooth. Fields appear normally and update works alright.

When I call the dialog to create a new entry, I get a set of blank fields, I fill them all, press save and works OK. Where is the problem? One of these fields should have already a value since I have already assign a value with the oModel.createEntry method. I debug the app the properties for the entry look alright, everything seems alright (if not blind) but the value doesn't come with the field - rings any bells?

Code (quite short) attached below, field in doubt: iAgrId.

Thanks!

Greg

		onActionAdd: function() {

				var oModel = this.getView().getModel();
				
				//oModel.createEntry("/Agreement_ActionsSet");
				var oActionEditDialog = new Dialog({title: "Create Action"});


				this.createActionFormData(oActionEditDialog, oModel);
				
				//get Agreement ID
				var sAgreement = this.getView().getBindingContext().toString().slice(16,26);
				var oNewObject = "{\"AgrId\": \"" + sAgreement + "\"}";
				oNewObject = JSON.parse(oNewObject);
				this.getView().addDependent(oActionEditDialog);
				var oEntry = oModel.createEntry("/Agreement_ActionsSet", oNewObject);
				oActionEditDialog.setBindingContext(oEntry);
				//oActionEditDialog.bindElement(oEntry);
				
				oActionEditDialog.open();
			},


			onActionEdit: function(oSourceEvent) {


				var oModel = this.getView().getModel();
				
				var oActionEditDialog = new Dialog({title: "Edit Action Details"});


				this.createActionFormData(oActionEditDialog, oModel);
				
				//to get access to the global model
				var sPath = oSourceEvent.getSource().getParent().getBindingContext().toString();
				this.getView().addDependent(oActionEditDialog);
				oActionEditDialog.bindElement(sPath);
				
				oActionEditDialog.open();
			},


			// populate form fields
			createActionFormData: function(oActionEditDialog, oModel) {


				var oActionTypeItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrActtypeid}", text:"{f4>AgrActtypeid}", additionalText:"{f4>AgrActtypetxt}"});
				var oActionStatusItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrStatid}", text:"{f4>AgrStatid}", additionalText:"{f4>AgrStattxt}"});
				var oActionAgentItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrAgentid}", text:"{f4>AgrAgentid}", additionalText:"{f4>AgrAgenttxt}"});


		        var sAgrId = new sap.m.Label({text: "{i18n>actionAgrId}"});
		        var iAgrId = new sap.m.Input({value: "{AgrId}"}); 				
		        var sAgrActionid = new sap.m.Label({text: "{i18n>actionLineItemTableIDColumn}"});
		        var iAgrActionid = new sap.m.Input({value: "{AgrActionid}", enabled: false}); 
		        var sCreatedBy = new sap.m.Label({text: "{i18n>actionCreatedBy}"});
		        var iCreatedBy = new sap.m.Input({value: "{CreatedBy}"});
		        var sCreatedOn = new sap.m.Label({text: "{i18n>actionCreatedOn}"});
		        var iCreatedOn = new sap.m.DatePicker({value: "{ path: 'CreatedOn', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
		        var sActionComment = new sap.m.Label({text: "{i18n>actionComment}"});
		        var iActionComment = new sap.m.Input({value: "{ActionComment}"});
		        var sAgrActionDate = new sap.m.Label({text: "{i18n>actionActionDate}"});
		        var iAgrActionDate = new sap.m.DatePicker({value: "{ path: 'AgrActionDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
		        var sAgrChaseDate = new sap.m.Label({text: "{i18n>actionChaseDate}"});
		        var iAgrChaseDate = new sap.m.DatePicker({value: "{ path: 'AgrChaseDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
		        var sAgrActtypeid = new sap.m.Label({text: "{i18n>actionActionType}"});
		        var iAgrActtypeid = new sap.m.ComboBox({ 
									//id: "cbRoleType", 
									selectedKey: "{AgrActtypeid}",
									//selectedItemId: "{AgrRoletptxt}",
									showSecondaryValues :  true,
									items: {
										path: "f4>/Action_TypesSet",
										template: oActionTypeItemTemplate,
										templateShareable: "false"}
						}).bindProperty("value", "AgrActtypeid");
		        var sAgrStatidFrom = new sap.m.Label({text: "{i18n>actionStatusFrom}"});
		        var iAgrStatidFrom = new sap.m.ComboBox({ 
									//id: "cbRoleType", 
									selectedKey: "{AgrStatidFrom}",
									//selectedItemId: "{AgrRoletptxt}",
									showSecondaryValues :  true,
									items: {
										path: "f4>/Agreement_StatusesSet",
										template: oActionStatusItemTemplate,
										templateShareable: "false"}
						}).bindProperty("value", "AgrStatidFrom");	
		        var sAgrStatidTo = new sap.m.Label({text: "{i18n>actionStatusTo}"});
		        var iAgrStatidTo = new sap.m.ComboBox({ 
									//id: "cbRoleType", 
									selectedKey: "{AgrStatidTo}",
									//selectedItemId: "{AgrRoletptxt}",
									showSecondaryValues :  true,
									items: {
										path: "f4>/Agreement_StatusesSet",
										template: oActionStatusItemTemplate,
										templateShareable: "false"}
						}).bindProperty("value", "AgrStatidTo");							
		        var sAgrAgentidFrom = new sap.m.Label({text: "{i18n>actionAgentFrom}"});
		        var iAgrAgentidFrom = new sap.m.ComboBox({ 
									//id: "cbRoleType", 
									selectedKey: "{AgrAgentidFrom}",
									//selectedItemId: "{AgrRoletptxt}",
									showSecondaryValues :  true,
									items: {
										path: "f4>/Agreement_AgentsSet",
										template: oActionAgentItemTemplate,
										templateShareable: "false"}
						}).bindProperty("value", "AgrAgentidFrom");
		        var sAgrAgentidTo = new sap.m.Label({text: "{i18n>actionAgentTo}"});
		        var iAgrAgentidTo = new sap.m.ComboBox({ 
									//id: "cbRoleType", 
									selectedKey: "{AgrAgentidTo}",
									//selectedItemId: "{AgrRoletptxt}",
									showSecondaryValues :  true,
									items: {
										path: "f4>/Agreement_AgentsSet",
										template: oActionAgentItemTemplate,
										templateShareable: "false"}
						}).bindProperty("value", "AgrAgentidTo");						
						
				var oSaveButton = new sap.ui.commons.Button({
	                        text: "Save",
	                        press: function (oEvent) {
								oModel.submitChanges({
									success: function(oData, sResponse) {
									},
									error: function(oError) {
										jQuery.sap.log.error("oData Failure", oError);
									}
								});		                        	
                                oEvent.getSource().getParent().close();
	                        }
	            });
				var oCancelButton = new sap.ui.commons.Button({
	                        text: "Cancel",
	                        press: function (oEvent) {
            					oModel.resetChanges();
                                oEvent.getSource().getParent().close();
	                        }
	            });


				oActionEditDialog.addContent(sAgrId);
				oActionEditDialog.addContent(iAgrId);				
				oActionEditDialog.addContent(sAgrActionid);
				oActionEditDialog.addContent(iAgrActionid);
				oActionEditDialog.addContent(sCreatedBy);
				oActionEditDialog.addContent(iCreatedBy);	
				oActionEditDialog.addContent(sCreatedOn);
				oActionEditDialog.addContent(iCreatedOn);				
				oActionEditDialog.addContent(sActionComment);
				oActionEditDialog.addContent(iActionComment);
				oActionEditDialog.addContent(sAgrActionDate);
				oActionEditDialog.addContent(iAgrActionDate);	
				oActionEditDialog.addContent(sAgrChaseDate);
				oActionEditDialog.addContent(iAgrChaseDate);				
				oActionEditDialog.addContent(sAgrActtypeid);
				oActionEditDialog.addContent(iAgrActtypeid);
				oActionEditDialog.addContent(sAgrStatidFrom);
				oActionEditDialog.addContent(iAgrStatidFrom);
				oActionEditDialog.addContent(sAgrStatidTo);
				oActionEditDialog.addContent(iAgrStatidTo);
				oActionEditDialog.addContent(sAgrAgentidFrom);
				oActionEditDialog.addContent(iAgrAgentidFrom);
				oActionEditDialog.addContent(sAgrAgentidTo);
				oActionEditDialog.addContent(iAgrAgentidTo);
				
				oActionEditDialog.addContent(oSaveButton);
				oActionEditDialog.addContent(oCancelButton);
			}

createentry.jpg (308.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 15 at 07:38 PM
    var oEntry = oModel.createEntry("/Agreement_ActionsSet", {properties:oNewObject});

    Add comment
    10|10000 characters needed characters exceeded