Skip to Content

SAPUI5 APP for Workflow Error -- - Cannot read property ‘startupParameters’ of undefined

Nov 15, 2017 at 10:21 AM


avatar image

I made a SAPUI5 APP for inserting to the workflow according to this artical:

How to build a simple approval UI

When I build the APP, there was an error facing:

Uncaught TypeError: Cannot read property 'startupParameters' of undefined

In the project, the wrong code that caused the error is in the Component.js:

var startupParameters = this.getComponentData().startupParameters;

in Debug, this.getComponentData() is undifined, it doesn't get a return value.

Does anybody know how could I solve the issue?

Here is the whole code:


], function(UIComponent, Device, models) {
	"use strict";

	return UIComponent.extend("LaunchWorkflow.Component", {

		metadata: {
			manifest: "json"

		 * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
		 * @public
		 * @override
		init: function() {
			// call the base component's init function
			UIComponent.prototype.init.apply(this, arguments);
			// enable routing
			var startupParameters = this.getComponentData().startupParameters;
			var taskModel = startupParameters.taskModel;
			var taskData = taskModel.getData();
			var taskId = taskData.InstanceID;

			// initialize model
			var contextModel = new sap.ui.model.json.JSONModel("/bpmworkflowruntime/rest/v1/task-instances/" + taskId + "/context");
			//add actions
				action: "Approve",
				label: "Approve"
			}, function(button){
				this._completeTask(taskId, true);
			}, this);
				action: "Reject",
				label: "Reject"
			}, function(button){
				this._completeTask(taskId, false);
			}, this);
		_completeTask: function(taskId, approvalStatus) {
			var token = this._fetchToken();
				url: "/bpmworkflowruntime/rest/v1/task-instances/" + taskId,
				method: "PATCH",
				contentType: "application/json",
				async: false,
				data: "{\"status\": \"COMPLETED\", \"context\": {\"approved\":\"" + approvalStatus + "\"}}",
				headers: {
					"X-CSRF-Token": token
		_fetchToken: function() {
			var token;
				url: "/bpmworkflowruntime/rest/v1/xsrf-token",
				method: "GET",
				async: false,
				headers: {
					"X-CSRF-Token": "Fetch"
				success: function(result, xhr, data) {
					token = data.getResponseHeader("X-CSRF-Token");
			return token;
		_refreshTask: function(taskId) {
			this.getComponentData().startupParameters.inboxAPI.updateTask("NA", taskId);

here is the image the APP after launching:

approve-reject.jpg (118.4 kB)
10 |10000 characters needed characters left characters exceeded


As I saw your comments exchange with the writer of the blog, I understand your question has been resolved. Please close this question and specify the solution.

* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
DJ Adams
Jan 24 at 07:18 PM

Hi - I would normally suggest that you're experiencing this problem as you're running your task UI app outside the context of the My Inbox app (e.g. testing it directly from within the SAP Web IDE) - but as you've shown a screenshot of the app running successfully, I'm a little confused.

But I'm going to guess that this is the problem despite the successful screenshot ... and point you to a post I wrote recently that describes this challenge, and how I overcame it. Look in particular at the section headed "Testing only".

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi DJ,

I'm very new in workflow. Recently I've read lots of articles were written by you and other experts. I'll read this blog you mentioned, and I'm glad to discuss it with you very soon.

Best Regards,

Joy Lee

Richard Zhao
Jan 12 at 05:22 AM

Hello, Junyi, I guess this issue is because the cache from the server not be cleaned. You could just rebuild your project, thanks

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I have thought it was my mistake.

Thank you,Richard