Use Scripting Job in SAP Hybris

Hybris featured image

1. Overview

The scripting job is a very particular job in Hybris, it gives you the possibility to run scripts of type Groovy, BeanShell or Javascript as a cronJob.

Scripting job in Hybris

  • Script : is a statement in Groovy, BeanShell or Javascript, in Hybris it’s an instance of the ScriptModel class.
  • Scripting Job : is an instance of the ScriptingJobModel, It takes as a parameter the URI to the script, the URI could use http, https, ftp, file, classpath or model.
  • Cron job : the cron job is an instance of the CronJobModel, it takes in parameter the Scripting Job.

In this article, I will show you how to create a scripting job in Hybris.

2. Scripting Job in action

2.1. Script

First, let’s create our script Groovy, via the impex.

INSERT_UPDATE Script;code[unique=true]	;scriptType(code)	;content
					;helloWorldScript	;GROOVY				;println "Hello World!"

2.2. Scripting Job

A scripting job is an instance of the ScriptingJobModel, the scripting job will be referring to our script helloWorldScript using URI of type model.

INSERT_UPDATE ScriptingJob	;code[unique=true]		;scriptURI
							;helloWorldScriptJob	;model://helloWorldScript

You can use any URI protocol (http, ftp, file, classpath…) you want for the scriptURI.

2.3. Cron Job

Last and not least, create an instance of the CronJobModel and attach to it the scripting job helloWorldScriptJob.

INSERT_UPDATE CronJob	;code[unique=true]			;job(code)				;sessionLanguage(isocode)	;sessionUser(uid)
						;helloWorldScriptCronJob	;helloWorldScriptJob	;en							;admin

Start the cron job helloWorldScriptCronJob manually from the HMc/Backoffice, or attach a trigger to it.

Start scripting Conjob from hmc in Hybris

If everything goes well, you should have a log similar to this :

18.09.25 00:22:39:247	INFO	### Starting executing script : model://helloWorldScript ###
18.09.25 00:22:39:247	INFO	Hello World!
18.09.25 00:22:39:247	INFO	### Finished executing script, returned script result = null ###


Leave a Reply

3 Comment threads
7 Thread replies
Most reacted comment
Hottest comment thread
6 Comment authors
yanLahcen ZbairvinayTejaMouad EL Fakir Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

newest oldest most voted
Notify of

brief, simple and useful, thank you (y)


simple and perfect explanation


what is the use of scripting?

Lahcen Zbair
Lahcen Zbair

Very interesting, will keep in mind … i was asking myself about some benefits, and I think there should be a lot: – Runtime extensibility: you can schedule technical / functional task while your Hybris is up an running (to be done in a moderate way, otherwise will end up with scattered codebase ) – Open the door to other languages (I know you have already Scripting console (HAC), but here you can do it in a periodic-basis) – It could be a good candidate to add orthogonal (ie not linked to a specific business case) functionality; exp: Schedule a… Read more »