An Interaction that populates a personal Data Suitcase

Here's the example mADL (PHP) code for an Interaction that populates a personal Data Suitcase and presents links that feed records out of the suitcase to the desired Form Interactions. For good measure, it even displays the contents of the Data Suitcase for confirmation. It accomplishes this all on a single screen.

For this example to work, you'll need to have a form named "suitcase" with at least of the same field names (case-sensitive) as those you can observe within the Data Suitcase (and the same Interaction names). The example doesn't do anything tricky with special field types, it really only covers the basic ideas, but it's almost an end-to-end example.

$name = 'datasuitcase';
$xml = <<< EOF
<xml>
  <suitcase>
    <id>1</id>
    <text>abcdefg</text>
    <checkbox>true</checkbox>
    <email>abc@yahoo.com</email>
    <currency>35.56</currency>
    <phone>65748</phone>
    <radioButton>One</radioButton>
    <select>Mango</select>
    <star>3</star>
    <multiSelect>China
      India</multiSelect>
    <checkboxes>c
      b</checkboxes>
    
  </suitcase>
  <suitcase>
    <id>2</id>
    <text>hijklm</text>
    <checkbox></checkbox>
    <email>abc@yahoo.com</email>
    <currency>35.56</currency>
    <phone>965748</phone>
    <radioButton>Four</radioButton>
    <select>Grapes</select>
    <star>1</star>
    <multiSelect>Australia 
      China</multiSelect>
    <checkboxes>c 
      d</checkboxes>
  </suitcase>

</xml>
EOF;

$html = <<< EOF
<h2>personal data suitcase</h2>
<p>suitcase: $name; successfully stored</p>
<ol>
  <li>
    <a interaction="SUITCASE_EDIT" mojo="datasuitcase" xpath="//suitcase[id=1]">edit</a>
    <a interaction="SUITCASE_VIEW" mojo="datasuitcase" xpath="//suitcase[id=1]">view</a>
  </li>
  <li>
    <a interaction="SUITCASE_EDIT" mojo="datasuitcase" xpath="//suitcase[id=2]">edit</a>
    <a interaction="SUITCASE_VIEW" mojo="datasuitcase" xpath="//suitcase[id=2]">view</a>
  </li>
</ol>
<h2>suitcase: $name</h2>
EOF;
$html .= '<pre>' . htmlspecialchars($xml) . '</pre>';

$control = array(
	'mojotarget' => $name, // replace or define $name to be a String
	'mojoxml' => $xml // replace or define $xml to be the XML String
);
$t->addControlMessage($control);

return $html . $t->result;


Note

The only way to retrieve data stored in a personal data suitcase is via XSLT Interactions on the client. We do not currently provide a JavaScript API to get to this data, and for technical reasons there can't be a PHP / MADL API to get to it either.