How to pass "previous " object in eventQueue() through Business rule and retrieve in Script Action..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 09:56 PM
Hi All,
I need to pass "previous " object in eventQueue() through Business rule and retrieve in Script Action. I am able to pass current object.. but I coudnt retrieve previous object wirh event.parm1.
Please suggest.
Regards,
Sumit Jumale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2016 12:29 AM
In that case write a lop routine that gets all the elements from the record and then makes it into a JSON string or into an array where each entry is composed of "element | value" and that is then passed to the eventQueue
so you would then pass
gs.eventQueue('test123',strEncoded,'','');
your even at the other end would need to decode your string and process it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2016 12:55 AM
Hi Julian,
I have tried using above mentioned logic... so in this case function like 'changesT()' is not working..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2016 02:24 AM
Hi Sumit,
Here is a start-to-finish example of how to use a JSON object to pass your previous values as a string. Keep in mind that the steps are 1) generate an object, 2) encode it to a string (that can be passed in your eventQueue statement), and finally 3) decoding the string to reconstitute your object so that you may work with its values in your script.
Business Rule script to capture
var previousValues = {};//Instantiate the object used to gather data
var fields = current.getFields();
for(var i=0;i<fields.size();i++){
var fieldName = fields.get(i).getName();
var elm = fields.get(i);// Get this field's element
if(elm.changes() && fieldName.indexOf('sys_') != 0){
previousValues[fieldName] = previous.getValue(fieldName);
}
}
var json = new JSON();
var strParm2 = json.encode(previousValues); //Encode the object to a string that can be passed as parm2
gs.eventQueue("your_eventname_here", current, gs.getUserID(), strParm2); //You don't have to pass the userID as parm1, I have just included it for the example
Later in your script, you will need to decode the encoded object to use it:
var json = new JSON();
var previousValues = json.decode(event.parm2);
//Here's an example of how you can iterate through the fields and access their current/previous values
for(var f in previousValues){
gs.log(f + " changed from " + previousValues[f] + " to " + current.getValue(f), "TEST SCRIPT");
}
I've adapted this from another example I wrote for doing the same thing but with mail scripts, but this should work just as well and is actually simpler. That example was passing both current AND previous values using the JSON object.
Give that a try, and hopefully it works ok for you.
Thanks,
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2016 03:19 AM
Hi Brain,
I have tried using above mentioned logic... so in this case function like 'changesT()' is not working..
please suggest...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2016 07:41 AM
Hi Sumit,
Please check your code, 'changeT()' is not correct.
It should be 'changes()'.
Please double-check this line.
Thanks,
-Brian