HP Anywhere 10.11 API Reference
Show:

HPA.Framework

Module: HPA

Available since HP Anywhere 10.02

Methods

addContextObjectToActivity

(
  • context
  • [silentType]
)

Available since HP Anywhere 10.02

Adds a context object or objects to an activity. If only one parameter is given, prompts the user to add the objects to either the current activity or to a new one. If an activity is not yet saved, adding to the current activity is disabled. If a second parameter is given (see below for valid values), adds the objects without prompting the user.

Usage Example:

var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");
HPA.Framework.isValidContextObject(ctxObj);
var silentType = "current"; //optional
HPA.Framework.addContextObjectToActivity(ctxObj,silentType);

Parameters:

  • context Object | Array

    A valid context object or an array of valid context objects. Create valid context objects using the createContextObject factory method. Test existing context objects for validity using the isValidContextObject method. For an invalid object, obtain detailed information using the validateContextObject method.

  • [silentType] String optional

    This parameter is used by the developer to add a context object without opening the Add Context Object dialog box. The developer determines whether to open a new activity for this context object or to remain in the current activity. This parameter has two valid values:

    • "new" - Create a new activity and add the context object to it.
    • "current" - Add the context object to the current activity if the activity exists, or, if there is no activity, create a new activity and add the context object to it.

    If a different string is given, it will be ignored and the user will be prompted to add to the current activity or to a new one.

createContextObject

(
  • objectId
  • dataType
  • displayName
  • [metaData]
)
Object | Null supports offline

Available since HP Anywhere 10.02

Creates a valid context object based on the arguments provided. After the object is created, it is validated by calling isValidContextObject. Use this method to create an entry point object, for example, before setting the current context of an app or adding the context object to an activity. A context object represents a business entity that is provided to the HP Anywhere framework by apps. For details, see the User Guide and Events Sample App Cookbook.

Usage Example:

 //the following information will be used to extend our context object
 var myData = {
   submitter: "John",
   owner: "Jason"
 };
 // construct a context object
 var contextObject = HPA.Framework.createContextObject('ID', 'DEFECT', 'Login failure', JSON.stringify(myData));
 // and an example without extending the context object
 var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");

Parameters:

  • objectId String

    ID of the context object; globally unique identifier.

  • dataType String

    Type of data of this context object.

  • displayName String

    Name of the context object. Maximum length: 100 characters.

  • [metaData] String optional

    An arbitrary string containing extra information. Maximum length: 2000 characters.

Returns:

Object | Null: Object containing the properties passed as arguments, or 'null' if the given arguments resulted in an invalid context object.

createEntryPointObject

(
  • appId
  • entryPointId
  • displayName
)
Object | Null supports offline

Available since HP Anywhere 10.02

Creates a valid entry point object based on the arguments provided. Use this method to create an entry point object, for example, before setting the current context of an app.


An entry point object represents a specific app page that is provided to the HP Anywhere framework by apps. For details, see the User Guide and Events Sample App Cookbook.

Usage Example:

HPA.Framework.createEntryPointObject("DefectManager","defect","open defect");

Parameters:

  • appId String

    ID of the app.

  • entryPointId String

    ID of the entry point.

  • displayName String

    Name of the entry point.

Returns:

Object | Null: Object containing the properties passed as arguments, or 'null' if one of the arguments is empty.

isAppAvailable

(
  • targetAppId
)
Boolean supports offline

Available since HP Anywhere 10.02

Use this method for cross-app use cases, for example, before opening a different app using the openEntryPoint method. Checks whether the given app is enabled for the current user.

Usage Example:

HPA.Framework.isAppAvailable("DefectManager");

Parameters:

  • targetAppId String

    ID of the required app. The ID of the app containing the entry point (app specific page).

Returns:

Boolean: True if the app is enabled for the current user.

isValidContextObject

(
  • contextObject
)
Boolean supports offline

Available since HP Anywhere 10.02

Use this utility method to make sure that a given object is a valid context object for the HPA framework. Validate that the context object is in the correct structure. This method returns a boolean value. If an object is invalid, use the validateContextObject method to get detailed information.

Usage Example:

var ctx = { objectId: objectId,
            dataType: dataType,
             displayName: displayName,
             metaData: metaData || '' };

HPA.Framework.isValidContextObject(ctx);

Parameters:

  • contextObject Object

    Context object to be tested for validity.

Returns:

Boolean: True if the given object is a valid context object.

openEntryPoint

(
  • targetAppId
  • entryPoint
  • [contextObjects]
  • [callback]
  • [scope]
  • [reuse]
)
async supports offline

Available since HP Anywhere 10.02

Opens a specific entry point in a specific app with optional context objects. Use this method for cross-app use cases (for example, to open an entry point (app specific page) in the same app, or to open a different entry point (app page) in another app).

Usage example:

var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");
HPA.Framework.openEntryPoint("DefectManager", "open", [ ctxObj ]);

Important: This method is different from the global openEntryPoint() method.

Important: Ajax server requests are asynchronous, and this call will return before the response has been received. Process any returned data in a callback function.

Parameters:

  • targetAppId String

    Target app ID. The ID of the app containing the entry point (app specific page).

  • entryPoint String

    Entry point ID. The ID of the actual entry point (app specific page).

  • [contextObjects] Array optional

    An array of context objects. An array of valid context objects. Create valid context objects using the createContextObject factory method; test existing context objects for validity using the isValidContextObject method; for an invalid object, obtain detailed information using the validateContextObject method.

  • [callback] Function optional

    Callback function to be called when the entry point opens.

  • [scope] Object optional

    The scope ('this' reference) in which the callback function is executed.

  • [reuse] Boolean optional

    [Desktop Edition] Whether to reuse the existing app instance.

openInnerPoint

(
  • displayName
  • callback
  • scope
  • [params]
  • [validationCallback]
  • [removeCallback]
)
async

Available since HP Anywhere 10.02

[Desktop Edition]

Mark the user state of the current app as an internal navigation point, so that the end-user can return to this point via the drop-down navigation menu.

Important: Ajax server requests are asynchronous, and this call will return before the response has been received. Process any returned data in a callback function.

Parameters:

  • displayName String

    Name to be displayed in the drop-down navigation menu.

  • callback Function

    Callback function to be called when the navigation point is selected, if the validation callback did not return False.

  • scope Object

    The scope ('this' reference) in which the callback functions are executed.

  • [params] Object optional

    Parameters to be passed as arguments when the callbacks are called.

  • [validationCallback] Function optional

    Callback function to be called just before switching to this page. If the function returns False, navigation to this page is canceled.

  • [removeCallback] Function optional

    [since HP Anywhere 10.01] Callback function to be called after this page is removed.

saveState

(
  • state
)

Available since HP Anywhere 10.02

Persist an object representing the current app state. There is no restriction on the object format; maximum size is 100kB (102,400 bytes). The state is saved per user, per activity, per app instance. When the user enters the app in the activity again, the last saved state is provided to the app, via its openEntryPoint method, params argument.

Parameters:

  • state Any

    An object in arbitrary format.

setActions

(
  • hideActions
)
deprecated supports offline

Deprecated use HPA.ActionsBar.setVisible for showing or hiding the Actions bar, and HPA.ActionsBar.setActions for customizing the Actions bar or restoring it to its default state.

Available since HP Anywhere 10.02

Hide or show the Action bar.

Parameters:

  • hideActions Boolean

    True to hide the Action bar, false to show it.

setCurrentContext

(
  • [context]
  • [entryPointObject]
)
supports offline

Available since HP Anywhere 10.02

Notify the HP Anywhere framework of the current context of the app. If the user adds a post in the timeline, objects in the current context that are not in the current activity are automatically added to the activity (no objects are deleted or updated).

Usage Example:

// the following information will be used to extend our context object.
var myData = {
    submitter: "John",
    owner: "Jason"
};
// construct a context object
var contextObject = HPA.Framework.createContextObject('ID', 'DEFECT', 'Login failure', JSON.stringify(myData));
//  notify HPA framework that the context of our app instance has changed.
// (upon user collaboration e.g. post,adding participant, this object will be silently added to activity's context.
HPA.Framework.setCurrentContext([contextObject]);
// create an entry point object which represents "defect list"  page of DefectManger app
var entryPointObject = HPA.Framework.createEntryPointObject('DefectManager', 'DEFECT_LIST', 'defects list');
// notify HPA framework that the context of our app instance has changed.
// (upon user collaboration e.g. post,adding participant, this object will be silently added to activity's context.
HPA.Framework.setCurrentContext([], entryPointObject);

Parameters:

  • [context] Object | Array optional

    A valid context object or an array of valid context objects. Create valid context objects using the factory method. Test existing context objects for validity using the isValidContextObject method. For an invalid object, obtain detailed information using the validateContextObject method.

  • [entryPointObject] Object optional

    A valid entry point object. Create valid entry point objects using the createEntryPointObject factory method.

setReady

(
  • readyState
)
supports offline

Available since HP Anywhere 10.02

Notify the HPA framework that the app is ready to accept entry point requests. This method must be called by the app developer whenever the app is loaded.

Usage example:

HPA.Framework.setReady(true);

Parameters:

  • readyState Boolean | Object

    [Object is deprecated since HP Anywhere 10.02; use True and see below for alternatives.] Either an object with the properties listed below, describing the relevant app capabilities, or simply the boolean True.

    • [hasDefaultAction] Boolean optional

      [Deprecated since HP Anywhere 10.02, use setActions to modify buttons.] [Smartphone Edition] Show an integrated default Action button in the Actions bar. The app needs to handle the DefaultAction entry point.

    • [moreActions] Array optional

      [Deprecated since HP Anywhere 10.02, use setActions to modify buttons.] [Smartphone Edition] Show integrated menu items in the More menu. The app needs to handle the MoreActions entry point.

    • [hasAutoContext] Boolean optional

      [Deprecated since HP Anywhere 10.02, use setCurrentContext to auto-inject context.] Support auto-injection of context objects. The app needs to handle the GetContextObjects entry point.

validateContextObject

(
  • contextObject
)
String[] supports offline

Available since HP Anywhere 10.02

Use this utility method to retrieve an array of messages that explains why a given object is not a valid context object for the HPA framework. Note: Messages are always returned in English.

Usage Example:

 var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");
 HPA.Framework.validateContextObject(ctxObj);

Parameters:

  • contextObject Object

    Context object to be tested for validity.

Returns:

String[]: Array of validation error messages, with length zero if the given object is valid.