jdehaas
I'm new here

Modifying elements within a workflow

Jump to solution

Guys,

We are running into a problem where we have an external component delivering content through a workflow.

The content needs to be inserted into a datasource. We want to use the the same view as the datasource entry form.

There comes the problem is that we want the user to see the content through the form and then persist it.

But the flow only allowes IDProviders as context which cant be changed.

So i cant modify an element within a workflow. Thats weird because the workflow could be doing businesslogic to modify input.

I need this for my customer, can anyone help.

Thanks,

Jeroen

0 Kudos
1 Solution

Accepted Solutions

Hello,

when I understand your posting right, you try to edit an entity of a datasource by using a script, which is started by a workflow?

Maybe this blogposting (click) can help you. It describes how to create, read, update and delete data records (entities) in FirstSpirit data sources by using a script.

best regards

Michaela

View solution in original post

0 Kudos
7 Replies
tklein
I'm new here

Hi Jereon,

I'm not sure if I understood the problem correctly,

> But the flow only allowes IDProviders as context which cant be changed.

You cannot get the Entity to make changes for that? Is it right?

You can get the Entity with this code:

workflowable = context.getWorkflowable();

if(workflowable instanceof ContentWorkflowable) {

     Entity = ((ContentWorkflowable) workflowable).getEntity();

}

If this doesn't solve your problem, please post some code here for a better support..

0 Kudos

Going to add some code will state when done.

0 Kudos

worflow ordina.png

Set data step: used from the external JMS Client that receives an event and start the worflow.

Verify: data, the idea is to do a technical validation of the xml event here (data xsd)

Edit:data: user can start a data form and verifies data, correct the data when necesariy.

Persist data: data will be persisted into the form datasource.

0 Kudos

Verify data script (Idea is to do an xsd check here we did a simple text check for purpose of simplicity)

Text is provide by the Java client.

#begin script

valid = false;

text = context.getWorkflowContext().getTask().getCustomAttributes().get("text");

if (text != null && !text.trim().equals("")) {

          valid = true;

}

if (valid) {

          context.doTransition("valid");

} else {

          context.doTransition("invalid");

}

0 Kudos

Persist data (allows editing and persist the data, simple text box will be a big form in the future implementation), Ideally we want to call the datasource form here but we cant edit data this is a open question!!!!:

#begin script

import javax.swing.JOptionPane;

import de.espirit.firstspirit.access.store.Store;

import de.espirit.firstspirit.access.store.IDProvider;

String showInput(String message,Object value) {

          return JOptionPane.showInputDialog(message,value);

}

lang = context.getProject().getMasterLanguage();

result = showInput("Please specify your text:", context.getWorkflowContext().getTask().getCustomAttributes().get("text"));

if (result != null && !result.trim().equals("")) {

          us = context.getUserService();

          cs = us.getStore(Store.Type.CONTENTSTORE, false);

          c2 = cs.getStoreElement("message", IDProvider.UidType.CONTENTSTORE);

          e = c2.getSchema().getSession().createEntity(c2.getEntityType().getName());

          ds = c2.getDataset(e);

          ds.setLock(true);

          fd = ds.getFormData();

          ff = fd.get(lang, "cs_text");

          ff.set(result);

          ds.setFormData(fd);

          ds.save();

          ds.release();

          ds.setLock(false);

}

context.doTransition("end_workflow");

0 Kudos

Hello,

when I understand your posting right, you try to edit an entity of a datasource by using a script, which is started by a workflow?

Maybe this blogposting (click) can help you. It describes how to create, read, update and delete data records (entities) in FirstSpirit data sources by using a script.

best regards

Michaela

0 Kudos
pavone
I'm new here

Hello Jeroen,

do you need further help or did Michaela's reply already help you? If so, it would be great if you marked her reply as "correct answer" so that other community users find the solution easily. If you have already found a solution by yourself, it would be very kind of you, if you posted it here.

Best regards

Tim

0 Kudos