Skip to main content

Hi,


How to get previous activity and current activity details for a process.


Thanks,


Shilpa



You can use the Activity Instance SmartObject (available out the box). You just need to pass in the Process Instance ID, order by Start Date Descending and select the top 2. This may not always work though if you have parallel processing.


 


For parallel processing, you may need to query the K2ServerLog db directly, it's not too difficult either. Start by getting the current activity ID (use the Serial number for that) and use the _Line table to get the previous activity (by accessing StartID and EndID fields). You can then query back to the _Act table (and _ActInst if needed).


As always, only do reads, no writes and ensure that the queries are not heavy as to avoid impacting performance on the system. If you are unsure about the db structure, the Data Dictionary is in the Help file.




Hi dc,


Thanks a lot for the response. It helped me. I have one more requirement. Once I get the activity instance Id i need to fetch the datafields associated for that activity. We need to save comments for every user action which we need to retriieve for every activity. How do I implement this?


Thanks,
Shilpa


This is a very common requirement and have been answered a few times, but I would create a separate table to store these (either SmartObject or custom DB Table) and then just retrieve these using SmO API or SQL queries.


By storing the data outside, it makes it easier to query, report on, etc. You can also easily customize the exact data structure you need, like action taken, Activity name, comments, fields updated, etc. Retrieval can then be done using your process instance id (also saved as part of your data structure).


Reply