<?xml version='1.0' ?>
  <klip>
     <identity>
        <title>
           API: Engines.Data.onCreate
        </title>
     </identity>
     <locations>
      <contentsource>
        http://support.klipfolio.com/files/demo/demo.xml
      </contentsource>
      <icon>
         http://www.klipfolio.com/static/klips/klipfolio/sample_icon.png
      </icon>
      <banner>
         http://www.klipfolio.com/static/klips/klipfolio/sample_banner.png   
      </banner>
     </locations>
     <setup>
        <refresh>
          1
        </refresh>
     </setup>
     <style>
        alert { 
           type: item;
	   definition: 'sender,summary,date,category,level,url,id,new_property';
        } 
        sender {
           itemcol: 2;
           noterow: 1;
           label: 'Sender';
           emphasis: strong;
        } 
        summary {
           itemcol: 3;
           noterow: 4;
           wrap: false;
           notelabel: false;
        } 
        date {
           itemcol: 4;
           noterow: 2;
           label: 'Date';
        } 
        category {
           noterow: 3;
           label: 'Category';
        } 
        level {
           itemcol: 1;
           noterow: 5;
           notelabel: false;
           type: image;
        } 
        new_property {
           noterow: 6;
           label: 'New Property';
        } 
        url {
           type: link;
        } 
        id {
           key: override;
        } 
  </style>
  <klipscript>
  <![CDATA[
  
function onRefresh() {
	Engines.Data.onCreate = myCreate; 
	Engines.Data.onUpdate = myUpdate; 

	return Engines.Data.process (Prefs.contentsource);
}

function myCreate( new_item )
{
	modify (new_item);

	return true;		// Create the item
}

function myUpdate( current_item, properties )
{
	modify (properties);

	return true;	      // Apply properties to current_item
}

function modify( pending )
{
	switch (pending.getData ("category")) 
	{
	    case 'Category 1': 
	    		pending.setData ("new_property", "First");
	    		break;
	    		
	    case 'Category 2': 
	    		pending.setData ("new_property", "Second");
	    		break;
	    		
	    case 'Category 3': 
	    		pending.setData ("new_property", "Third");
	    		break;
	}

	return true;
 }
	 

    ]]>
    </klipscript>
</klip>