Populate metadata date field from XML file?


(James) #1

Hi,

 

Is it possible to populate a metadata 'date' field from an XML file?  I can grab the date value OK from an XML file using asset_file_contents keyword replacement modifier to get the correct XML tag contents.

By adding this as the default value of a metadata field in the schema it appears fine in the metadata, however, I can only do this if I use a text field, not a date field.  The problem with using a text field is I can't then set up a Search page asset to use against it to search a date range, only specific dates.  So to cut a long story short how do I dynamically populate a metadata 'date' field?

 

Thanks


(Bart Banda) #2

Sounds like you would need a trigger or a separate action to populate the date field. So whatever your action is, could be an ajax call to the page with a specific query number, you could run some trigger action to set the metadata date field. But depends on how and where you are accessing the XML file from. 


(James) #3

Ah yes that might work.  The XML file is pulled in using one of the Squiz php import scripts run using a CRON job each day. 

 

Perhaps I could use the create asset trigger and then the set metadata value action.  Found the description below in the manuals, looks hopeful.  I'll give it a go, thanks for the suggestion.

 

Set Metadata Value

This action will set the value of a metadata field. The fields that are available for this action are shown in the figure below.

clear1x1.gif The Set Metadata Value action

Select the metadata field to set in the field provided and click Commit - additional fields will appear. Set the value of the metadata field in the field provided. Alternatively, you can use the Parameter and Source fields to populate the metadata field with information from the asset that fired the event.


(James) #4

Quick update - it worked :D

 

Had to make sure the date field in the XML file was YYYY-MM-DD e.g. 2005-08-15.

 

Thanks again for the suggestion.


(Bart Banda) #5

Nice work!