Skip to main content

Actions

The actions method is used if you need to trigger new processing - which could be processing another schema or pushing generated views to a third-party application - using web hooks or such as Algolia.

ActionsContext object

The ActionsContext object is passed into the actions method and gives you access to the reprocess and destination functions which are described below.

Methods

MethodDescription
reprocessReprocess a schema based on its alias.
destinationSpecifies the destination where the generated view is pushed to.

reprocess

reprocess(schemaAlias)

Parameters

ParameterTypeDescription
schemaAliasstringThe alias of a schema.

Required function calls

After the reprocess function it's required to call one of the following functions to define what source entities you want to reprocess.

byOriginId

Use the byOriginId function to reprocess a specific entity based on its originId.

Parameters

ParameterTypeDescription
originIdstringThe original id from the source system.
reprocess by byOriginId
context
.reprocess('mySchemaAlias')
.byOriginId(sourceEntity.properties.link.id)
bySchema

Use the bySchema function to reprocess all source entities a specific schema has a trigger on.

Caution: Often it's better to reprocess a specific source entity instead a schema and all of its matching source entities, but sometimes it's necessary to reprocess an entire schema.

reprocess by bySchema
context
.reprocess('mySchemaAlias')
.bySchema()
parent

Use the parent function to reprocess the parent entity based on its originParentId.

reprocess by byOriginId
context
.reprocess('mySchemaAlias')
.parent()

Optional function calls

After one of the required function call above, there are extra functions you can call.

sourceGroup

Defines the source group of an source entity to process. If the source entity you want to reprocess is located in another source group than the current source entity, you must specific the source group.

Note: sourceGroup can't be used on parent as parent is implicit in the same source group as the child.

Parameters

ParameterTypeDescription
sourceGroupAliasstringThe alias of the source group for the source entity you want to reprocess.
reprocess by origin id and source group
context
.reprocess("mySchemaAlias")
.byOriginId(sourceEntity.properties.link.id)
.sourceGroup('anotherSourceGroup')

destination

destination(destinationAlias)

The destination method is used to push generated views for a schema to a webhook, to Algolia or another third-party application.

Parameters

ParameterTypeDescription
destinationAliasstringThe alias of the destination you want the generated view is pushed to.

Examples

actions example
actions: function(sourceEntity, context) {
context.reprocess('productCategory')
.byOriginId(sourceEntity.properties.productCategoryPage.id)
.sourceGroup('commerce');
context.reprocess('productCategory')
.parent();
context.destination('webhook');
}
actions can also be expressed as an arrow function expression to make it even more compact
actions: (sourceEntity, context) => context.reprocess('productCategory').parent()