Expand my Community achievements bar.

SOLVED

Fire Workflow Launcher on Content Fragment save

Avatar

Level 3

I'm trying to configure a workflow launcher to fire when a content fragment is saved and not before. Currently, my launcher is configured like this:

 

Event Type: Modified

Nodetype: dam:Asset

Path: /content/dam/mysite/us/en/content-fragments/insights(/.*)

Run Mode: Author

Conditions:

jcr:content/data/master/cq:tags!=

jcr:content/data/master/insight-title!=

jcr:content/data/cq:model==/conf/mysite/settings/dam/cfm/models/insight

Workflow: MyWorkflow

 

The conditions keep it from firing unless insight-title field is populated, there are cq:tags, and the model is of type "insight", but if those conditions are met, the launcher fires BEFORE the content fragment form is saved if any of the fields on it are touched. I know this because the WorkflowProcess implementation I've written fires the execute method as soon as the cursor leaves a field on the form after changing it and before saving.

 

I have been looking at the /jcr:content/data/master/fieldname@LastModified fields hoping to see these field changes recorded before save so I could write a condition to account for them, but they appear unchanged until save.

 

Is there a way to write a launcher which will fire on save of a content fragment instead of when a field is touched in the form but not yet saved?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @mpalme1,

I am able to reproduce the scenario in my local with your launcher configuration. 

I tried changing the launcher config as below and it was triggering only upon save (and not when we move out of the field)

Event Type : Modified

Path : /content/dam/learnings/content-fragments/events(/.*/)jcr:content/data(/.*)

NodeType : nt:unstructured

Conditionsmaster/eventTitle!=covid

Please try and let know if it works for you. Screenshot below for reference

You can cross verify in Workflow Instances(Running) / Workflow Archive(completed) console based on the execution status of the workflow.

Vijayalakshmi_S_0-1599677529374.png

 

View solution in original post

11 Replies

Avatar

Correct answer by
Community Advisor

Hi @mpalme1,

I am able to reproduce the scenario in my local with your launcher configuration. 

I tried changing the launcher config as below and it was triggering only upon save (and not when we move out of the field)

Event Type : Modified

Path : /content/dam/learnings/content-fragments/events(/.*/)jcr:content/data(/.*)

NodeType : nt:unstructured

Conditionsmaster/eventTitle!=covid

Please try and let know if it works for you. Screenshot below for reference

You can cross verify in Workflow Instances(Running) / Workflow Archive(completed) console based on the execution status of the workflow.

Vijayalakshmi_S_0-1599677529374.png

 

Avatar

Level 3
Thanks, @Vijayalakshmi_S. In my case, there are a variable number of folders between /content-fragments and /jcr:content/data. I'm not clear from any of the documentation I've looked at what syntax is supported for path conditions. Is this documented anywhere? Is it some limited form of regex?

Avatar

Community Advisor

Hi @mpalme1,

It is the regular regex pattern for paths, no explicit mention of the syntax.

Can you share your existing hierarchy of content fragments (considering all possible paths), we will arrive at generic way of path pattern. 

Avatar

Level 3

Oh, wow, Vijayalakshmi_S, thank you. That is very kind. I would appreciate the help.

 

Ok, so, if I have content fragments "article-about-weather", "article-about-sports", "article-about-fashion", and "article-about-politics",  the paths to those content fragments could look like this:

/content/dam/mysite/us/en/content-fragments/insights/legacy/articles/article-about-weather

/content/dam/mysite/us/en/content-fragments/insights/2020/articles/article-about-sports

/content/dam/mysite/us/en/content-fragments/insights/2019/articles/article-about-fashion

/content/dam/mysite/us/en/content-fragments/insights/articles/article-about-politics

 

I expect the content authors managing the DAM to add additional folders in the future such as 

/content/dam/mysite/us/en/content-fragments/insights/2021/articles

where they will put future content fragments of the same "article" type.

 

Avatar

Community Advisor

Hi @mpalme1,

You can use below as "Path" considering the paths you have shared

  • /content/dam/mysite/us/en/content-fragments/insights(/.*)(articles/.*/)jcr:content/data(/.*)

This will also work if any variation is created in future for any of these content fragments whose path would something be like - 

/content/dam/mysite/us/en/content-fragments/insights/2021/articles/test-article/jcr:content/data/mobile-variation. 

Updated launcher config is as follows:

Event Type : Modified

Path : /content/dam/mysite/us/en/content-fragments/insights(/.*)(articles/.*/)jcr:content/data(/.*)

NodeType : nt:unstructured

Conditions eventTitle!=covid

Avatar

Level 3

@Vijayalakshmi_S, would my conditions

  • jcr:content/data/master/cq:tags!=
  • jcr:content/data/master/insight-title!=
  • jcr:content/data/cq:model==/conf/mysite/settings/dam/cfm/models/insight

become

  • master/cq:tags!=
  • master/insight-title!=
  • cq:model==/conf/mysite/settings/dam/cfm/models/insight

?

Avatar

Community Advisor

Ignore my previous comment

Third condition is not correct. We have given the path one level after /data node. cq:model is not visible on that path. Hence third is not correct. 

First two will work. You can either give master/cq:tags!= or simply cq:tags!=

Avatar

Level 3

@Vijayalakshmi_S  Thank you so much for all your help. I got it working now.