Skip to main content

ALToolbox.save_input_data

random_alphanumeric​

get_current_info​

safe_json​

DADict​

DAList​

DAObject​

date​

time​

Decimal​

math​

Dict​

List​

Any​

Optional​

__all__​

_serialize_input_value​

def _serialize_input_value(value: Any) -> Any

Keep data types where possible, preferring useful object display text.

save_input_data​

def save_input_data(title: str = "",
input_dict: Optional[Dict[str, Any]] = None,
tags: Optional[List[str]] = None) -> None

Save survey interview input data to JSON storage for data reporting purposes.

Processes and stores user input data from survey-type interviews into the Docassemble JSON storage system. Automatically handles type inference and flattening of complex data structures like checkboxes and multiselect fields. Dates use ISO format and Decimals become floats. Objects with a useful __str__ method are saved as display text (for example, an individual's name); other objects and native containers are serialized with safe_json. If an object's string method raises an exception, safe_json is used instead.

Arguments​

  • title str, optional - A descriptive title for this data entry. Defaults to "".
  • input_dict Optional[Dict[str, Any]], optional - Dictionary mapping field names to their values from interview questions, including primitives, dates, Decimals, containers, and Docassemble objects. If None, an empty dict is used. Defaults to None.
  • tags Optional[List[str]], optional - List of string tags to associate with this data entry for categorization and filtering. Defaults to None.

Notes​

  • This function saves data to storage but does not return anything
  • Checkbox and multiselect fields (DADict) are automatically flattened so each option becomes a separate database column with a boolean value
  • Each call creates one database record per interview session
  • Data is stored with a random 32-character alphanumeric key

Example​

After collecting feedback_was_helpful and feedback_comments, call this once in the feedback submission flow:

Input (interview YAML)

code: |
save_input_data(
title="Interview feedback",
input_dict=\{"helpful": feedback_was_helpful, "comments": feedback_comments\},
tags=["feedback"],
)
feedback_saved = True