Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Use as Process Participant

Injected Variables:

 

    • pluginManager - Plugin Manager service bean for convenient usage. (org.joget.plugin.base.PluginManager)
    • workflowActivity - Workflow Activity that trying to retrieves assignee. (org.joget.workflow.model.WorkflowActivity)

 

Expected Return Object:

    • A java.util.Collection of username in java.lang.String to be assign to the Workflow Activity.

Samples:

Use as Process Tool 

Injected Variables:

 

Expected Return Object:

Samples:

...

    • A boolean value to indicate the user is authorized.

Samples:

 

Best Practices

 

1. Only import classes that are needed

 

 

Do not use wildcard in import statement. It giving a very bad performance in Bean Shell interpreter to search the whole package and loads it in memory.

Don't:

Code Block
languagejava
import java.util.*;

Do:

Code Block
languagejava
import java.util.Collection;

 

 

 

2. Do not need to mention the type of element of a collections

Bean Shell interpreter cannot recognise the element type syntax of collections class like Collection, Map, List, Set and etc.

Don't:

Code Block
languagejava
Map<String, String> map = new HashMap<String, String>();

Do:

Code Block
languagejava
Map map = new HashMap();

3. Indents your script nicely and follows the Java Code Conventions

 

It will make yours and others life easier to maintain and review the script whenever necessary as Joget Workflow provided flexibility to adapt change quickly.

4. Write your script in functions

If your script is pretty long and some parts of the script are reusable, please make use of function to write your script. It provided better reading and performance.

5. Remember to write some comments 

It will helps you and others to understand what is the purpose for the script quickly. 

6. Catch the exceptions and give a meaningful message in log.

If you are using a log of Bean Shell Scripting in your app, a meaningful log message can help you to locate your issue quickly.

Don't

Code Block
try {
    //do something
} catch (Exception e) {
    LogUtil.error("BeanShell", e, "Error executing script");
}

Do:

Code Block
languagejava
try {
    //do something
} catch (Exception e) {
    LogUtil.error("CRM app - Backend userview", e, "Error retrieving user department in Report category permission");
}