Extender Scripts

Orchid has implemented PYTHON 3 scripting around the Sage 300 Views and Sage 300 desktop screens, so site specific business logic can be implemented using PYTHON 3 scripting and applied to Sage 300 core and 3rd Party Views (if they are developed in the Sage 300 SDK) – when records are inserted, updated and deleted.

There are four main types of scripts: 

  • View scripts , attached to a specific view field or view operation such as Insert or Update
  • UI Scripts - to open a screen on the Sage 300 desktop. Such scripts can be used to maintain Sage 300 core data, records in Extender custom tables, or gather input to trigger a process.
  • Screen scripts subclass Sage 300 OCX screens and are used to add buttons, hide / add fields, to Sage 300 screens.
  • Workflow Action scripts

How to use the Script List

The Scripts screen lists all scripts which have been uploaded to the current company. The script name, Status(Active/Inactive) and Checked In/Out status will be shown, together with the first few comment rows of the currently selected script for verification. You can also see if the script is Viewable and Has a password.

You can upload new scripts from this screen or create new ones.

Tip:

Insert a new row and type a script name to create a new script.

When you create a new script, you get a different default script based on the script name.

  • If your script has ".WORKFLOW." in the name, you get the workflow sample script.

  • If your script is subclassing a UI (ie it has a .XXYYYY. in the name) then you get a ui subclass sample script.

  • If your script has ".UI." in the name, or ends ".UI", then you get a sample ui script

  • Otherwise you get a sample view script.

You can also right-hand-mouse-button on any script and

  • View the script
  • Check out the script
  • Undo the checkout of a script
  • Select an Editor
  • Add the script to the Sage 300 Desktop.

Add a Script to the Sage desktop

Select a script, right-click on the script and select "Add the script to the desktop"

This option brings up the tree of the existing menu, and allows you to select which branch the script must be placed.

Note: To create new folders in the tree, use the Insert key on your keyboard, enter a name and select the new folder. Extender cannot add a script to a folder created using the Sage New Folder menu.

Delete a script from the desktop

In Extender Setup > Scripts, as a user with Extender Admin rights, select the script, right click on it, and choose “Add to desktop”.

Find the script in the Sage 300 menu where it was added.

In the example screenshot, the script was added to the Extender > Inquiries menu, you need to find the script in that menu.

Then use the DELETE key on the keyboard.

To save, there is a little trick… You need to use the X cross on the top right and Save the changes. Restart the Sage desktop. The script should be removed for all users.

Note: This doesn't delete the script, it just removes it from the Sage 300 desktop for all users.

Viewing and editing scripts

With Extender PU6 and above, you can hide and/or password protect scripts.

Scripts can have two optional lines in them:

#! password=xxx

#! viewable=true or #!viewable=false

Tip:

On the Scripts screen, if you double click on the Password column, you are prompted to add / remove a password.

If you double click on the "viewable" column, you are prompted to add/remove a password.

If you have a password set then by default, the script is not viewable unless you add the viewable=true line. You can't checkout the script unless you know the password, and the script is not stored as plain text on the disk.

When you choose Edit, you will be prompted to enter the password. Scripts can be edited without re-entering the password until you close the Custom Scripts screen.

How to apply an OCX Screen script

With Extender PU4 and above, you can also add scripts to Sage 300 Desktop screens (OCXs).

USE Screen scripts to: 

  • Add tabs, fields, buttons and finders to the Sage 300 desktop screens
  • Hide/Remove tabs, fields, buttons and finders on a Sage 300 desktop screen
  • Change finders and buttons on a Sage 300 desktop screen
  • Interact with the underlying datasources. (Previously scripts only operated at the View level, and therefore were not always reflected on the screen.).

    Example: You can add row to an order and refresh the grid to view the row, or interact with optional fields.

Writing a OCX screen script name:

Name of a screen script (OCX script)

  • Must contain the RotoID of the required screen, surrounded by a full stop and
  • Must have the RotoID on the first line of a script, following a hash (comment) marker (#OE1100 for an Order Entry Screen script).
  • The combinations below are all valid, where RotoID is the ID of the Sage screen, for example AR1300 for the AR Customer Screen.

{rotoID}

{anytext}.{rotoID}

{anytext}.{rotoID}.{anytext}

{rotoID}.{anytext}

Tip: If the script is called OE1100_myscript, it is not active as a screen script.

Example:

Script Name

For Scripts without a module name:

OE1100.NewScript.py

If you are deploying your OCX script as part of module, and the module name is “Orchid.MyModule”, then the OCX script would be called:

Orchid.MyModule.OE1100.NewScript.py

The first line of the script must be:

# OE1100

Tip:

To disable a screen script,

Edit the script and add at least 2 comment characters.

Copy

Disable a OCX Screen script

### OE1100
# such a screen script is disabled.

Workflow Action scripts

An action is a Python script that is stored in the database just like regular user scripts.

Configurator includes a number of predefined actions. For details, refer to Configurator Actions

A workflow script can have up to 4 parameters passed to the script from the workflow template.

At the top of the script, add a new comment line, starting with ## then add P1 and the name you want to give the parameter. The name will appear in the Workflow Template, Action Grid and F9 zoom screen. For details on setting up Workflow templates, refer to Workflow Templates - Screen Guide.

# P1 Parameter1Name You can name up to 4 parameters that can be configured in the workflow template.

# P2 Parameter2Name

# P3 Parameter3Name

# P4 Parameter4Name

Example:

Look at the Workflow.Evaluate script: 

#Instructions for your script go here

## P1 Field

## P2 Operator < <= > >= <> = # you can use either <> or !=, and also = or ==

## P3 Value

 

The field names when using the Evaluate action will show as

Field, "Operator < <= > >= <> =" and Value

Resources

Get Started with Python 3 Script