Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

AEM 6.4 Workflow - Assign Task - Advanced - Use custom Metadata - ECMA getUserMetaData() - how to get Workflow Metadata .. workItem Error

Avatar

Avatar
Validate 1
Level 1
wendelinfa
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
View profile

Avatar
Validate 1
Level 1
wendelinfa
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
View profile
wendelinfa
Level 1

18-08-2020

We try to use Workflow Metadata inside Assign Task notification eMail.

 

Sample https://docs.adobe.com/content/help/en/experience-manager-64/forms/publish-process-aem-forms/use-met... is working fine.

 

When using var wfmetadata = workItem.getWorkflow().getMetaDataMap(); 

witch is working in participantChoser getParticipant() we get error

/apps/fd/dashboard/scripts/metadataScripts/kpbTaskMetaData_v1.ecma: ReferenceError: "workItem" is not defined. (NO_SCRIPT_NAME#28)

 

Please advice how to get Workflow Metadata based on ECMA Script in Assign Task

 

Thanks for any help

 

Regards Wendelin

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile
gbedekar
Level 3

20-08-2020

So if you are having a problem in 6.4 version, Please log a support ticket. The following code is working fine in 6.5 environment

function getUserMetaData() {
//Commented lines below provide an overview on how to set user metadata in map and return it.
var payloadPath = workItem.getWorkflowData().getPayload().toString();
log.info("The size is "+workItem.getWorkflowData().getMetaDataMap().size());
log.info("The path is "+payloadPath);

var path = workItem.getWorkflowData().getPayload().toString();
var dataFilePath = path+"/Data.xml/jcr:content";
var xPath = Packages.javax.xml.xpath.XPathFactory.newInstance().newXPath();
var factory = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
var builder = factory.newDocumentBuilder();
var session = workflowSession.adaptTo(Packages.javax.jcr.Session);
var xmlDataNode = session.getNode(dataFilePath);
var xmlDataStream = xmlDataNode.getProperty("jcr:data").getBinary().getStream();
var xPath = Packages.javax.xml.xpath.XPathFactory.newInstance().newXPath();
factory = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
xmlDocument = builder.parse(xmlDataStream);

node = xPath.compile("afData/afUnboundData/data/firstName").evaluate(xmlDocument, Packages.javax.xml.xpath.XPathConstants.NODE);
log.info("#####"+node.getTextContent());

 

var HashMap = Packages.java.util.HashMap;
var valuesMap = new HashMap();
valuesMap.put("policyNumber", payloadPath);
valuesMap.put("policyHolder", payloadPath);

return valuesMap;
}

Answers (5)

Answers (5)

Avatar

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile
gbedekar
Level 3

19-08-2020

this is working in the ecma script

var workflowData = workItem.getWorkflowData();

var payloadPath = workItem.getWorkflowData().getPayload().toString();

log.info("The path is "+payloadPath);

Once you get the payloadPath, you can acces the submitteddata and from there do the rest

I recommend creating osgi service to do this

Let us know if you have problems

 

Avatar

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile
gbedekar
Level 3

19-08-2020

I have reached out to engineering and should have an answer to you soon

Avatar

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile

Avatar
Boost 25
Level 3
gbedekar
Level 3

Likes

26 likes

Total Posts

34 posts

Correct Reply

9 solutions
Top badges earned
Boost 25
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile
gbedekar
Level 3

18-08-2020

Avatar

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

327 likes

Total Posts

1,150 posts

Correct Reply

185 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

327 likes

Total Posts

1,150 posts

Correct Reply

185 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile
Mayank_Gandhi
Level 10

18-08-2020

Avatar

Avatar
Ignite 1
Level 7
GirishBedekar
Level 7

Likes

167 likes

Total Posts

239 posts

Correct Reply

37 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Ignite 1
Level 7
GirishBedekar
Level 7

Likes

167 likes

Total Posts

239 posts

Correct Reply

37 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
GirishBedekar
Level 7

18-08-2020

Will get back to you on this