Coding Methods Guidelines

The code of a method can, for example, contain assignments, concatenations of the internal name of methods, etc.

This page discusses:

See Also
OTScript Method Presentation

Guidelines

To write specific methods in the OTScript tab, you need to know the datamodels of the objects you work with and the internal names of these objects.

  • You can find the internal name of methods you want to insert in the code by hovering over their names in the Data tab, before dropping them into the coding area.
  • You can also hover over loops in the work area to know the types of methods they are expecting.

Examples

An example of an OTScript method, which lets you list bookmarked documents is as follows:

PACKAGE PLM;

METHOD Workspace.getBookmarkedUniqueDocuments() -doc : {
    `rel_Data Vaults`.`to_Workspace Vault`.`rel_Vaulted Objects`.to_Document.SELECTUNIQUE(id);
} LABEL "Contained Documents without duplication"

You can define a shortcut method to overwrite the physical products navigation in a product structure. This customized method lets you display the product titles following a sort criterion based on the titles. For more information, see About the Creation of Shortcut Methods.

PACKAGE PLM;
METHOD rel_VPMInstance.getReferenceTitle() -doc : GetReferencePLMReference.V_Name LABEL "Reference Title";
METHOD VPMReference.getSubProductReferences() -doc : SubProducts.GetReferencePLMReference[EACH ISA VPMReference] LABEL "Sub Product References";

Method Call

A method accepts parameters as arguments. Any valid code can be passed as arguments to a provided method or an own method.

In OTScript, arguments are passed as follows to a method: receiver.method(arg1, arg2).

Note: Here is a list of special calls:
  • receiver.method() or receiver.method: If method does not need arguments.
  • receiver.method1(…).method2(…): Corresponds to a chained method call. method1 is applied on receiver and method2 is applied on the result of the previous call. For more information, see Member Access.
  • EACH.method(…) or method(…): Applies method on the current object EACH.
    Note: EACH is equivalent to THIS at the first level.
  • THIS.method(…): Applies method on THIS in the case of an iteration. For more information, see Predefined Variables.
  • ^EACH.method(…), ^^EACH.method(…), etc.: Calls method in the parent context. For more information, see Predefined Variables.