activity.previous_activity

ctsmith
Mega Sage

Hi, this is in relation to the following post:   REST Activity error handling (Eureka)

I responded to the thread, but I don't think anyone's looking at it again, and I bit under the gun...

Basically, my question is this:

Can you explain why this works (and it does work for me), exactly?

var history = new GlideRecord('wf_history');

history.get(activity.previous_activity);

workflow.scratchpad.RESTError = history.output;

Specifically, the 2nd line and the "previous_activity" part.   I know line two is get values from the activity field in the wf_history table, but how is properly matching up to the current request item with .previoius_activity?

I'm using this on a workflow script to pull in the XML (stored in wf_history table output field) of a SOAP response into a variable based on the above code:

var history = new GlideRecord('wf_history');

history.get(activity.previous_activity);

current.variables.aws_xml = history.output;

Will this always pull in the correct output into the correct RITM or RFTASK?     Are there other activity.* calls like activity.current_activity?

Thanks!

1 ACCEPTED SOLUTION

If the activities are "far apart"... don't know. I might consider using the workflow scratchpad at that point.



http://wiki.servicenow.com/index.php?title=Using_the_Workflow_Scratchpad


View solution in original post

11 REPLIES 11

Chuck Tomasi
Tera Patron

Hi Chris,



activity is an object known to your workflow scripts, so it is just doing a GlideRecord get on the sys_id in wf_history that corresponds to activity.previous_activity.



Will it always work? I guess that depends on what happened in the previous activity.


I guess I'm worried about... is it calling the right previous_activity?   The one for the current REQ only?   Or could it be some other user's previous_activity?   Is this related to activity.output?



Thanks!



Chris


Not to worry - relational databases to the rescue! YAY!



It's related to the current record you are on, which has a current workflow, which has the wf_history for that context.



The only place I can see this possibly going off the rails is if you had multiple workflows (contexts) attached to a record. Haven't tired. It's a corner case IMHO.


Ahh, that makes sense.   What other things are stored in the activity object?   Any documentation on this?



Chris