• March 18, 2026
  • Kishore Thutaram
  • 0

Implement a message on server timeout by using setTimeout function in SAP UI5

Requirement: Implement the timeout function with a threshold value by raising an error message when the ODATA server call gets timed out.

File: Controller.js

Implement the code below.


	callSave: function () {
         //set timeout at 5 minutes threshold
	this.oTimeout = setTimeout(this.onTimeoutAction.bind(this), 300000);
               //ODATA call
         	oModel.create("/HeaderSet", oEntry, {
				success: function (oData, response) {
                                 }
                                 	error: function (oData) {
                                   }
                               	});             
          }
         
// on Timeout implement the message
  onTimeoutAction: function () {
			
MessageBox.show("Order creation is still in progress. Order number will be emailed to you in approximately 15 mins.", {
				icon: MessageBox.Icon.WARNING,
				title: "Timeout",
				actions: [MessageBox.Action.OK],
				onClose: function (oAction) {
					if (oAction === MessageBox.Action.OK) {
						window.location.reload(true);
					}
				}
			});
		},
// Clear timeout if user leaves the page before time expires
		onExit: function () {
			
			if (this.oTimeout) {
				clearTimeout(this.oTimeout);
			}
		}
   
    

Kishore Thutaram

SAP Solution Architect | 16+ Years' Experience in SAP | Sharing Practical SAP Knowledge | Engineering Graduate with Expertise in SAP Architecture

https://fiowelt.com