Update multiple assets at once


(Willh) #1

Can anyone tell me how to update many assets at once? Maybe a BatchRequest in the JS API?

 

Assume that I have an asset listing which is presenting the metadata fields from many Data Record assets. I want a member of staff to update a field from all the listed assets. The new data is specific to each asset so it can't be cascaded from a parent asset. Import won't work either as I don't have structured data to work from.

 

Can this be done through the Admin Interface, Easy Edit Suite or just within a standard page?

 

 

Many thanks

Will

 


(Anthony) #2

I dont know any way through the admin interface or EES, but that doesnt mean it cant be done, and someone else might enlighten you. I am reasonably proficient with javascript and the Squiz API so personally speaking thats the route I would go. I did something vaguely similar not too long ago. If you make your asset listing output nicely structured HTML so you put the asset number in the id of a div / span with a specific class, for example, then a trivial bit of jquery would nicely loop through them all and fire off the relevant calls in Squiz.

 

Remember metadata is case sensitive when you need to reference the field names in code! Wasted hours on that when I first tried it.


(Nic Hubbard) #3

I have done this with triggers. Sometimes doing it that way is easier than using the JS API.

 

Build an asset listing that lists your assets, with input fields for the attributes you want updated. Then, setup a trigger, with the asset accessed action and some conditions. Then just have the user fill in the fields, somewhere referencing the URL of that asset. Then, have your submit button run some JS to loop through each field, POSTing that data to its URL.


(K Dennis) #4

I've had some success with a similar task using an asset listing to create an xml input file for use with the script "import_from_xml.php".

 

Put code like this in your type format:

<action>
   <action_id>set_Page_Standard_%asset_assetid%__metadata_field_7590</action_id>
   <action_type>set_metadata_value</action_type>
   <asset>[%asset_assetid%</asset>
   <fieldid>7590</fieldid>
   <value><![CDATA[^metadata_7590_value^]]></value>
</action>

add the opening and closing tags <actions> and </actions> to complete the xml file.

 

then you can manually add your new metadata to replace the phrase "^metadata_7590_value^" in the code above.