Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

how do i use SetValue functions in executeScript activity.

Avatar

Level 7

Hi,

Could anyone let me know how to use function from setValue acitivity (serialize, concate, count etc) in executeScript activity. What all liberaries that i need to import to executeScript. I want to perform the same task in executeScript that is performed in setValue activity.

Regards

Sunil Gupta

1 Accepted Solution

Avatar

Correct answer by
Level 3

Forgive me if I seem obtuse, but why would you want to use XPath functions (that's what serialize, concat, and count are) when there are perfectly good Java alternatives that will be so much easier to use.  Java is, after all, the language used in executeScript.  Serialize is just toString(), concatenate is just + or .concat() (I'm assuming you're running Java 6 on the web app server).  The count function is just length() or size() methods or, for arrays, the length property.  If you really need to re-arrange the data in an XML variable use an XSL stylesheet - you have access to all the XPath 1.0 functions and the power of XPath 1.0 and you don't need to mess around with the headache of trying to debug Java in an environment (Workbench) that doesn't give you any of the tools you'd normally have, like a context-sensitive editor.

View solution in original post

9 Replies

Avatar

Former Community Member

Hi Sunil Gupta,

ExecuteScript uses Beanshell scripting.

We can set values to variables using ExecuteScript using

patExecContext.

For more details refer to below link,

http://help.adobe.com/en_US/livecycle/10.0/WorkbenchHelp/WS92d06802c76abadb-1cc35bda128261a20dd-7173...

Avatar

Former Community Member

If you wanted to use concatenate as an example, you could do:

String temp = patExecContext.getProcessDataStringValue("{String copied from a setValue step that gives you what you want}");

patExecContext.setProcessDataStringValue("{String copied from a setValue step where you want the value to go}", temp);

Although you could just get all the pieces you want to concatenate and concatenate in the bean shell code

String temp1 = patExecContext.getProcessDataStringValue("{Value 1}");

String temp2 = patExecContext.getProcessDataStringValue("{Value 2}");

String temp3 = patExecContext.getProcessDataStringValue("{Value 3}");

patExecContext.setProcessDataStringValue("{String copied from a setValue step where you want the value to go}", temp1 + temp2 + temp3);

Avatar

Level 7

I think my questions are not clear. I want to use all funtions that appears in setValue acitivity (serialize, concate, count etc) with the same parameters in executeScript activity.

Avatar

Former Community Member

I understand the concept of what you want to do. I gave you example execustScript code, you just have to plug in the XPath.

If you want the answer to be specific, please give specific XPath expressions for from and to that you would otherwise put in a setValue.

Avatar

Correct answer by
Level 3

Forgive me if I seem obtuse, but why would you want to use XPath functions (that's what serialize, concat, and count are) when there are perfectly good Java alternatives that will be so much easier to use.  Java is, after all, the language used in executeScript.  Serialize is just toString(), concatenate is just + or .concat() (I'm assuming you're running Java 6 on the web app server).  The count function is just length() or size() methods or, for arrays, the length property.  If you really need to re-arrange the data in an XML variable use an XSL stylesheet - you have access to all the XPath 1.0 functions and the power of XPath 1.0 and you don't need to mess around with the headache of trying to debug Java in an environment (Workbench) that doesn't give you any of the tools you'd normally have, like a context-sensitive editor.

Avatar

Former Community Member

Don makes a good point. I was probably thinking something had to be done in Execute Script and Sunil didn't want to learn Java to do the other things. But if there is already a learning curve, you might as well pick the one that is more efficient.

Avatar

Level 7

Don,

I understand what you say. I just wanted to know if workbench liberary can be used or not in executeScript so that i can excuse workbench functions.

thanks Don and Steve..

Regards

Sunil

Avatar

Level 3

Sunil, I guess I can see your question as an exercise in testing the completeness of the patExecContext implementation.  However, some of the functions in the XPath Builder are just attempts to expose a Java construct to a user who doesn't know Java.  For example, adding an item to a map object in XPath builder is done by setting Location to /process_data/map[@id='mapKey'] and Expression to the desired value.  In Java that's just

  map.put("mapKey", valueObject);

On the other hand, XPath selectors can build a node list in one line that would take several lines of Java to execute.  I think you'll just have to experiment and build the list yourself.

Avatar

Level 7

thanks Don, its really great help..