Scripts Advanced Tips

Remember original values in scripts

You can configure what fields Extender tracks the original value in View Events, Scripts and Workflow. Refer to Remember Original Values For: 

As tracking the original values for all fields for all views can have a performance impact, you can now configure what fields you need the original value for in a script.

The value configured in View Events, Scripts and WF takes precedence. If the Remember Original Values for is set to *, then Extender will remember all fields. If it is set to DESC, and the script includes "IDCUST,NAMECUST", Extender will add both and will track "DESC,IDCUST,NAMECUST".

Copy

rememberOriginalValue

def onOpen():
  rememberOriginalValue(“field,field,field”)
return Continue

Python environment

As of PU11.00, view scripts can share a python interpreter. Shared environments are faster.

When using shared environments, the onOpen function needs to return a class. See example below.

You specify which environment you want your script to run in using env(environment_name) at the top of the script.

If there is no env line then the script will get its own interpreter.

If script A has env(env1), and script B and C have env(env2)

then all instances of script A will run in env1,

and all instances of scripts B and C will run in env2.

To use

Add a env line in the script

#@ env(environment_name)

Copy

Using Shared Environment in a view script

#@ env(environment_name)

from accpac import *

class MyView(View):
    def __init__(self):
        View.__init__(self)

    def onBeforePut(self, e):
        rvspyTrace(getMyRotoID() + " put to " + e.field)
        if e.field == "CUSTOMER":
            rvspyTrace("Changing CUSTOMER from " + self.get("CUSTOMER") + " to " + e.value)
        return Continue

# onOpen is called when the view is opened.
# Return an object to enable the macro.
# Return 0 to disable the macro.
# If you return anything else then the view will not load.
def onOpen():
    return MyView()

Tip: Create a new view script in Extender Views to get an example as above