In the controller rules we update some of the process variables using a stored procedure due to some complex calculations etc etc.
However this leaves the Workitem_context cache out of date.
How do I refresh this cache from the database?
However this leaves the Workitem_context cache out of date.
How do I refresh this cache from the database?
RE: Force the Workitem Cache to refresh from database
1. Manually reload the data from the rlvntdata table and assign the values to the Workitem Context PVs. This was overwritten by the data in the cache which then saved it backed t the database when loading a partial page.
2. After doing 1 above saving the workitem contect back to the cache workitem_context but it doesn't seem to work as I assume the workitem context isn't held in the structure I'm supplying it and resulted in a blank form
3. Remove the workitem_context cache - this didn't force the reload of the cache and gave the same result as 2.
RE: Force the Workitem Cache to refresh from database
Sorry for the delay in getting back to you on this.
Unfortunately, this is something that is not quite as easy to do as you think it might be, but the approach below should work.
Create a rule in your Controller with the following actions:
Retrieve the +?+?++bizflow_details+?+?+? session cache information which contains the initial parameters received from BizFlow, and place it into +?+?++/mvc:eForm/mvc :D ata+?+?+?
Add a number of assign actions to set the values from this into the Control section. When doing this make sure the +?+?++Create if it does not already exist?+?+?+? option is checked. (If using an earlier WebMaker version where this option is not available you will need to use an insert action first.)
The +?+?++to location+?+?+? and +?+?++xpath to value+?+?+? xpaths that you should use for each assign action are as follows:
Then delete the existing out-of-date WorkitemContext information at +?+?++/mvc:eForm/mvc :D ata/WorkitemContext+?+?+?, and the bizflow_details fragment temporarily inserted at +?+?++/mvc:eForm/mvc :D ata/bizflow_details+?+?+?.
Finally use an Invoke Service action to call the GetWICDetails controller in your project. Send all the information to this controller, so use a from and to xpath of just +?+?++/+?+?+?.
This approach will cause the whole WorkitemContext structure to be retrieved from BizFlow again, and the cached information stored updated accordingly.
The screen shot below shows the setup of all the actions required.
[attachment=0]updateWICrules.png[/attachment]
If you know the updated values for the process variables (eg if they are returned by your stored procedure) then there is an alternative approach of updating the cached data directly.
Unfortunately, the information initially returned by BizFlow (and stored in the cache) is in a slightly different format to that available yo you in the controller. So after updating the WorkitemContext structure you have, you would then need to retrieve the cached details (using a +?+?++cache id+?+?+? of +?+?++workitem_context+?+?+?, and a +?+?++scope+?+?+? of +?+?++Session+?+?+?) and then update this structure as well, before saving it back to the cache.
The format of this cached structure includes a ProcessVariable element for each PV, which contains a Name and Value child element amongst others. So you would need to update the correct Value element for a given Name.
This would be a good place to use a variable in the rules if you do go down this route, but given the complexity, and the fact that you would need additional actions for each PV to update, etc, I think the first option is probably the best one to use.
I hope this helps.
Regards,
Gerard
RE: Force the Workitem Cache to refresh from database
Thanks very much!
Hawk