Show TOC

Procedure documentationScripting in the Shell Locate this document in the navigation structure

 

The Shell allows you to access the Repository directly with a scripting language. You can use it to automate repetitive tasks, for example, submit 10 jobs. It can also be used to write or debug your RedwoodScript or Redwood Expression Language code as well.

Note Note

The shell requires the Scripting module.

End of the note.

By default, the scripting locale is set to English, you can change it to German using the following code:

importPackage(java.util);

jcsSession.setLocale(Locale.GERMAN);

Procedure

  1. Navigate to   Scripting → Shell  .

  2. Enter your code in the lower pane.

  3. Choose Submit Command.

    1. The result of your code will be printed in the upper pane.

  4. Close the tab when you are finished.

Example

To submit one job without parameters, you could use the following code:

{

// Get the job definition object

JobDefinition jobDefinition = jcsSession.getJobDefinitionByName("System_Info");

// Create a job object

Job job = jobDefinition.prepare();

// To submit the job, you need to commit changes to the database

jcsSession.persist();

}

To submit 10 jobs without setting any parameters, you could use the following code:

{

// Get the job definition object

JobDefinition jobDefinition = jcsSession.getJobDefinitionByName("System_Info");

for (int i = 0; i < 10; i++)

{

// Create a job object

jobDefinition.prepare();

}

// To submit the jobs, you need to commit changes to the database

jcsSession.persist();

}