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
Solved! Go to Solution.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Hi Sunil Gupta,
ExecuteScript uses Beanshell scripting.
We can set values to variables using ExecuteScript using
For more details refer to below link,
Views
Replies
Total Likes
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);
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
thanks Don, its really great help..
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies