PDA

View Full Version : How to Generate a GUID in an XAction



ngoodman
05-01-2008, 11:50 PM
I needed to uniquely identify a request to Pentaho (one particular action sequence request). Found a pretty darn easy way to do this with the help from Java RMI classes.
- Insert a Javascript data source
http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011651-tm.jpg (http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011651.jpg)
- Enter the following script

function getGUID() {
var VMID = new Packages.java.rmi.dgc.VMID();
return VMID.toString();
}
getGUID();
- Set return type as “string” for a new value
http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011650-1-tm.jpg (http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011650-1.jpg)
- Add it to your response
http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011652-tm.jpg (http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011652.jpg)
http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011653-tm.jpg (http://www.nicholasgoodman.com/bt/blog/wp-content/uploads/2008/05/200805011653.jpg)

- Enjoy your GUIDs!
cef9372c035a42ed:-b0917ee:119a6d47d72:-7ff4
cef9372c035a42ed:-b0917ee:119a6d47d72:-7ff3
cef9372c035a42ed:-b0917ee:119a6d47d72:-7ff2
PS - I personally hate GUIDs when stored in the database. http://www.nicholasgoodman.com/bt/blog/wp-includes/images/smilies/icon_smile.gif However, for matching up with a particular request, yippeee!!



More... (http://www.nicholasgoodman.com/bt/blog/2008/05/01/how-to-generate-a-guid-in-an-xaction/)