Pular para o conteúdo principal
Base de Conhecimento da FocusVision

Using the Logic Library

This document provides detailed instructions on using the Logic Library and its re-usable logic segments, or "logic nodes".


The Logic Library is a system that allows you to easily access reusable code within a survey. With the Logic Library you can re-use Python code between projects similar to when you add styles and Javascript code for dynamic questions.

1:  How to Create a Logic Node

While accessing a survey's XML, you can add a <logic> tag to your survey with logic that runs code when encountered.

These logic elements are known as "logic nodes", and each one has at minimum the following attributes:

<logic label="marker"
uses="dmarker.1" />
  • The label attribute uniquely identifies a logic node, similar to specifying a question label. Logic nodes that store data will store it under the unique label. Just like a question, the label also creates a variable in Python code that provides additional functionality that is dependent on the marker.
  • The uses attribute selects the name and version of the logic node.  Similar to dynamic questions, functionality is versioned so that version 1 of a logic node stays unchanged, receiving only bug fixes.

Each logic node may take parameters. Some logic can be scheduled to run at some point in the future: either once or repeatedly. From the logic library page, if you have Decipher Cloud access, you can view all possible logic elements with a description. You can view the logic library page at:


2:  Debugging Information

If you have a survey with logic nodes, you can view a list of all the logic nodes and any debug information that has been logged on the project logic debugging page.  Select "Logic" from the Report menu or use the direct link:


From the command line, you can issue the command "beacon get schedule" to get a list of what actions scheduled and for when. You can issue the command "beacon post surveys/{survey}/logic/{label}/trigger" to trigger an event.

Once a node is added, a "Logic" menu item is available for debugging from the Report menu:

3:  Scheduling Logic Nodes

Some logic nodes are scheduled to run periodically such as those for sharing the field report and crosstabs, while others (such as the nodes for clearing data and closing a survey) are scheduled to run only once.

The following applies to all logic nodes:

  • The nodes never trigger automatically in any temp-XXX survey
  • If you visit the project logic debugging page, you can ask for the node to trigger immediately, even in testing surveys. This can be used to verify that file data delivery works correctly
  • The action is scheduled when the survey is loaded and only when the survey is live. Thus if you edit the survey.xml in the shell, you must also load the survey.
  • Any errors from the action are sent via email to all the subscribers on the survey
  • If an error occurs when executing the trigger, it will be retried after 1 hour, 2 hours etc. All survey subscribers are notified of the failure.
  • The node triggers under the credentials of the oldest subscriber to the survey that is still an active user (likely the project launcher) or failing that, under the system user hermes@decipherinc.com. Future versions of the logic system will have a way to embed a specific user's credentials

The following applies only to periodic logic nodes:

  • The next scheduled time can be seen in the project logic debugging page.
  • If the node triggers and the survey is still live, it is re-scheduled according to the selected period. If the survey is closed, the node can still trigger but it will not be re-scheduled
  • Modifying the time or period the node fires triggers a reschedule: the existing scheduling is canceled and a new one is added
  • Este artigo foi útil?