Extending oajsapi

With the oajsapi class you can implement your own custom methods.

In order to use a custom method, you need to execute the following steps:

  • Copy the file "WssUserRequestHandler.ctl" from the installation folder <wincc_oa_path>/scripts/libs/classes/wssServer to your local project folder <project_path>/scripts/libs/classes/wssServer.

  • Modify "WssUserRequestHandler.ctl".

    Remove the delimiters from the switch block and add your method as a case.

  • Use the new method via the oajsapi method "customFunction".

This Example adds the method "dpTypeGet" and uses it via the "customFunction" method.

The method "dpTypeGet" is already present as an example case within "WssUserRequestHandler.ctl". It will be usable once the delimiters around the switch structure are removed.

Then, add the oajsapi method "customFunction" to use "dpTypeGet":

oaJsApi.customFunction('dpTypeGet', {typeName: 'ExampleDP_Int',
includeSubTypes: false}, 
{
  success: function(data) 
  {
    console.log(data);
  }
  ,error: function() 
  {
    console.error(arguments);
  }
}
);