• "In Use?" flags on States/Roles/Notifications not refreshed when selected in Actions

    By Kevin Pettitt 2 decades ago

    This probably applies to conditions, validations, etc. as well…



    When you have created the "shell" of various States, Roles, Notifications, Actions, etc., there are places on the Action form where you can point to the other document types. E.g. An Action can be "Restricted to These States" by selecting from a list of available states. There is a field called "QenosWFInUse" on all State, Role, Notification, etc. documents which calculates to 1 if used somewhere in an Action (or anywhere else probably, so the following may have broader impact), and 0 if not.



    The Problem: This field is not recalculating on the downstream documents when they are selected for use in some action. A simple document refresh fixes this, but this is not obvious.



    It is probably not necessary to trigger a fullblown document refresh of all downstream documents when an action is saved, since flipping the
    QenosWFInUse flag is probably sufficient. I know there is already code elsewhere that detects when a change in one document requires updates to others. Perhaps that same approach can be used here. If not, it should be fairly easy to generate a list of document unique ids (i.e. aRefNo values) through the following formula (may be incomplete):



    @Trim(a_CondRefNo : a_CondRefNo1 : a_NextResponsibleRolesRefNo : a_NextStateParentWFRefNo : a_NextStateRefNo : a_NextStateRefNoParent : a_NotificationRefNo : a_NotificationRolesRefNo1 : a_NotificationRolesRefNo2 : a_NotificationRolesRefNo3 : a_NotificationRolesRefNo4 : a_ParentActionTriggerRefNo : a_RestrictRefNo : a_RestrictStatesRefNo : a_ValidationRefNo)



    So that you could handle cases where downstream documents were both selected AND deselected on the action, you would want to do a before and after list of the above field values, and generate a "superlist" containing both. So that you don't refresh the flag unnecessarily on the downstream documents, you could loop through each downstream document and only refresh the flag if a change has been made on the current action. Only save the document in those cases. On the offchance that any of those documents is currently open, leave the "force" flag of doc.save to false.



    Because a downstream State document, for example, might be used by a different action than the one being edited, you cannot simply flip the QenosWFInUse flag to false. You would need to recalculate this field as if resaving that document directly. For this reason, the refresh code for the downstream documents should probably be triggered in the PostSave of the action as opposed to the querysave, so that calculation can take into account any changes to the current action.



    As for the downstream refresh itself, you could simply do a doc.ComputeWithform, and this is probably fine considering the nature of those documents (i.e. relatively simple). You could even do a before/after value check on the
    QenosWFInUse flag and only save the doc if a change was actually made. Alternatively, you might be able to use a Lotusscript Evaluate statement and include the formula for the field itself, as opposed to rewriting the logic in pure Lotusscript. Even in that case some sort of before/after save only if changed logic could still apply.

    • possible approaches

      By Mark Demicoli 2 decades ago

      On workflow component postsave, these are the options I see:


      1. Execute the InUse formula against all components in the same workflow and update if changed.

        PROS: fast - only updating a single field (not computeWithForm), and only if required.

        CONS: prone to save conflicts therefore inaccurate



        or, a different approach altogether


      2. Remove InUse column entirely from the embedded Qenos Designer view, and produce an 'In Use' report when the Designer requests it (eg via a button).

        PROS: faster - no updating of related documents; no save conflicts therefore more accurate.

        CONS: not as nice as displaying in-view (though could still display it in view - may confuse some since a manual process is required to update it).



        PS. I so wish you could use @DBLookup in view columns :) Yes i know how dangerous it is.
      • ..further

        By Mark Demicoli 2 decades ago

        just realised that you'd have to check all global docs aswell (ie for option 1).



        Any other possibilities? Option 2 looking more attractive.