cancel
Showing results for 
Search instead for 
Did you mean: 

Refreshing current date in sapui5 application while screen is not refreshed

0 Kudos

Hello Experts,

I have an sapui5 application in launchpad where posting of data happens for days without refreshing the session or application. But the problem I am facing here is that even after setting the current date in the model every time the date is not refreshed, like it takes the date when first session login happens after that it continues to take the same date. But if I refresh the browser screen the model again takes the current date and same thing goes on if I do not refresh.

Can anyone please tell me how do I deal with this problem.

Below is the local model in model.js and setting of the date in controller.

localModel.setProperty("/processData/PostingDate", new Date());
localModel.setProperty("/processData/DocumentDate", new Date());
Header.PostingDate = localModel.getProperty("/processData/PostingDate");
Header.DocumentDate = localModel.getProperty("/processData/DocumentDate");
"processData": {
					"Purchaseordernumber": null,
					"Deliverynumber": null,
					"PostingDate": null,
					"DocumentDate": null,
					"productionOrderNumber": null,
					"processOrdernumber": null
				},

Accepted Solutions (0)

Answers (2)

Answers (2)

junwu
Active Contributor
0 Kudos

where is your code to set the date again? if you only set it once, how can it change later if you don't set it again?

0 Kudos
This function runs every time when posting happens. do I still have to set it again. Not sure about it it.


onPostGoods: function () {
			var localModel = this.getModel("LocalDataModel"),
				PurchaseOrder = localModel.getProperty("/processData/Purchaseordernumber"),
				OutBoundDelivery = localModel.getProperty("/processData/Deliverynumber"),
				processOrder = localModel.getProperty("/processData/processOrdernumber"),
				prodOrder = localModel.getProperty("/processData/productionOrderNumber"),
				Items = [],
				Header = {},
				sPath,
				i,
				tableItems = localModel.getProperty("/itemData"),
				headerData = localModel.getProperty("/goodsIssueData"),
				table;
			localModel.setProperty("/processData/PostingDate", new Date());
			localModel.setProperty("/processData/DocumentDate", new Date());
			Header.PostingDate = localModel.getProperty("/processData/PostingDate");
			Header.DocumentDate = localModel.getProperty("/processData/DocumentDate");

			Header.CreationDate = localModel.getProperty("/goodsIssueData/ProductionDate");
}
junwu
Active Contributor
0 Kudos

when you debug, it didn't show you the current date?

localModel.setProperty("/processData/PostingDate", new Date());
			localModel.setProperty("/processData/DocumentDate", new Date());
			Header.PostingDate = localModel.getProperty("/processData/PostingDate");
			Header.DocumentDate = localModel.getProperty("/processData/DocumentDate");
0 Kudos

Yes on debugging it shows current date.

junwu
Active Contributor
0 Kudos

then where you see the old date?

duncanbarre
Participant
0 Kudos

have you tried: localModel.refresh() or localModel.updateBindings()

0 Kudos

Yes I have used model.refresh()