Show TOC

Handling Startup ParametersLocate this document in the navigation structure

Handling of startup parameters that are encoded in the URL.

Note The startup parameters are part of the URL and stored in the browser history. This may be a security or data protection issue. If you pass security-critical content, use an anonymized format and keep the sensitive data within your back end application.
Note The length of a browser URL is limited and truncation may occur. Keep the length of the URL fragment below 512 characters.
Note Information is transferred to the front-end server as part of navigation target resolution. This information may be persisted on the front-end server.
Passing Startup Parameters Dynamically with JavaScript

An app can dynamically pass parameters to another app using the CrossApplicationNavigation service. The following code snippet shows an example:

var href_For_Product_display = ( sap.ushell && sap.ushell.Container &&
sap.ushell.Container.getService("CrossApplicationNavigation").hrefForExternal({
  target : { semanticObject : "Product", action : "display" },
  params : { "ProductID" : "102343333", SupplierId : "90210" }
})) || "";
Receiving Startup Parameters Dynamically with JavaScript

Startup parameters are received by an embedded component by calling the getComponentData method, which returns a startupParameters member. The following code snippet shows an example:

sap.ui.core.UIComponent.extend("AppNavSample.Component", {
  ...
  createContent : function() {
    /*
     * getComponentData() returns an object like { startupParameters : { AAA : ["BBB"], DEF: ["HIJ","KLM"] } }
     * NOTE: parameters values are passed via arrays
    */
    var oComponentData = this.getComponentData();
    jQuery.sap.log("app was started with parameters " +
JSON.stringify(oComponentData.startupParameters || {} ));
  ...
  }
});
Note

The parameter values are always passed into an array inside the object returned by getComponentData().

Consuming Startup Parameters from Inside an Embedded View

For views created by the SAPUI5 routing framework or directly from within the component, you can locate and identify the component using getOwnerIdFor. The following code snippet shows an example:

// view controller.
   getMyComponent: function() {
     "use strict";
     var sComponentId = sap.ui.core.Component.getOwnerIdFor(this.getView());
     return sap.ui.component(sComponentId);
   }
   onCreate : function() {
     …
     var oStartupParameters = this.getMyComponent().getComponentData().startupParameters;
   }
...

For more information, see sap.ui.core.Component.

Other Sources of Startup Parameters

To set startup parameters for an app, the following options exist:

  • Passing the startup parameters dynamically from the source app as described above.
  • Setting the startup parameters in the configuration of a navigation target in transaction LPD_CUST, see Customizing Navigation Targets.
  • Defining the startup parameters in configuration (target mapping).
  • User enters them manually in the URL.
Note Startup parameters are transparent to the end user in the URL and may be tampered with or serialized with minimal efforts.
Passing Query Parameters in a Stand-alone Index Page

If you use a stand-alone index page for testing your app in a local environment, you can pass the query parameters to the component as shown in the following example:

<head>
…
<script>
  var oStartupParameters = jQuery.sap.getUriParameters().mParams;
  var oComponent = sap.ui.getCore().createComponent({
    name: "sap.samples.SampleComponent",
    settings: {
      componentData: { startupParameters: oStartupParameters }
    }
  });
  new sap.ui.core.ComponentContainer({
    component: oComponent
   }).placeAt("content");

</script>
</head>
<body>
  <div id=”content”/>
</body>