SelectByTemplate Auto-Save

posted Jan 2, 2019, 10:46 AM by Eric Patrick   [ updated Jan 2, 2019, 10:47 AM ]
The GenericObject class in QBO offers a SelectByTemplate method to enforce repeatability. Two recent changes were introduced that can have unexpected consequences for existing installations:
  • {Table}Template and {Table}TemplateID may be used as synonyms for Template and TemplateID
  • SelectByTemplate no longer calls Save when detecting a new instance of a class
Background

QBO has always supported the concept of templated repeatability as:
  • One generic object per parent
  • One active generic object per parent, and
  • Many generic objects per parent
For example, one can defined a DecisionTemplate called "Invoice Client" as one active per parent where calling 

Decision/Save?Object=Organization&ObjectID=1&Template=Invoice Client

will result in:
  • If an existing Invoice Client workflow exists and is open, it will be "reused" (no new workflow is created),
  • If an existing Invoice Client workflow exists and is not open, a new Invoice Client workflow will be created, or
  • If no existing Invoice Client workflow exists, a new Invoice Client workflow will be created
However, the following method signatures did not abide by repeatability rules:

Decision/Save?Object=Organization&ObjectID=1&DecisionTemplate=Invoice Client
Decision/Save?Object=Organization&ObjectID=1&DecisionTemplateID=X

This exposed a bug in the ITemplate.CreateInstance pattern, where the {Table}TemplateID property was being set, instead of TemplateID, causing repeatability to be ignored when creating generic objects from workflows.

The fix for this now supports methods signature using {Table}Template or {Table}TemplateID, but in turn exposed another bug:

SetProperties?Object=Organization&ObjectID=1&DecisionTemplateID=X

triggers a Save call.  Normally, this save call has no effective impact, because SelectByTemplate is almost always called from Save anyway. However, when adding a Message from the UI, Message/Merge is called, which in turn calls Message/SelectByTemplate, which triggered a Save on the Merge, even if a user never clicks Save.

Given the broad impact of removing the SelectByTemplate Save call, this change has been feature-switched:

qbo.Application.Properties.Settings.SelectByTemplateAutoSave = false

If this change results in undesirable behavior of a given installation, take the following steps:
  • From Design > Modules > Matrix > Settings, change the qbo.Application.Properties.Settings.SelectByTemplateAutoSave setting to true
  • Notify Quandis support of your specific use case so our architecture team can consider workarounds

Comments