Editing metadata of mutiple assets

I have a whole lot of assets that I need to change the metadata of. Specifically, they are ecommerce products and I need to add stock numbers and quantities. If there were just a few, I would edit each one using the easy edit suite. However, there are hundreds.


Is there a way of generating an asset listing that will list the assets (maybe 100 at a time) and with each include the metadata values in input fields, which I can then change and submit?



Thanks.

I have done this before by setting up a trigger then building an asset listing with some javascript.


Basically each asset was listed with its metadata in an input field, when I changed it there was a submit button next to each asset. Clicking that would use the asset url and send the new value. The trigger had an asset accessed event with a URL matches condition. Then I passed the new metadata value in as a get var.

[quote]
I have done this before by setting up a trigger then building an asset listing with some javascript.



Basically each asset was listed with its metadata in an input field, when I changed it there was a submit button next to each asset. Clicking that would use the asset url and send the new value. The trigger had an asset accessed event with a URL matches condition. Then I passed the new metadata value in as a get var.

[/quote]



Hi Nic. I think I came across this while searching the forum's archives and I was going to get in touch with you personally. This sounds like exactly what I want. I don't suppose you could describe what you did in slightly more detail. It would be a huge help to me.



Thanks.

[quote]
Hi Nic. I think I came across this while searching the forum’s archives and I was going to get in touch with you personally. This sounds like exactly what I want. I don’t suppose you could describe what you did in slightly more detail. It would be a huge help to me.

[/quote]



Sure, take a look at this jsbin page I setup: http://jsbin.com/oqotug/3/edit#javascript,html



As for setting up the trigger you would use the following:



Event -

Accessed URL



Condition -

URL Match (use action=update)

Asset Type or Tree Location to Narrow it down

Permissions: Write (so only you can update these)



Action -

Update Metadata field (set it for a get var of metaVal)



Then setup your asset listing type format like:


      
      


Hope that helps.

Nic, that is fantastic.


Unfortunately, I'm not able to get it to work properly. I cannot get it to accept the GET variable.



The trigger works, which I can verify by getting it to set the metadata field to a constant value. But if I set it to a GET variable instead, it doesn't work. Is there something I might be missing about how to set up a parameter and a source? (Come to think of it, I don't think I have ever successfully set up a trigger using a dynamic parameter.) I have set 'Parameter' to 'Metadata Field Value' and chose 'GET Variable Name' and then added 'metaVal' to the field. There's nothing else I need to do is there?

[quote]
Nic, that is fantastic.



Unfortunately, I'm not able to get it to work properly. I cannot get it to accept the GET variable.



The trigger works, which I can verify by getting it to set the metadata field to a constant value. But if I set it to a GET variable instead, it doesn't work. Is there something I might be missing about how to set up a parameter and a source? (Come to think of it, I don't think I have ever successfully set up a trigger using a dynamic parameter.) I have set 'Parameter' to 'Metadata Field Value' and chose 'GET Variable Name' and then added 'metaVal' to the field. There's nothing else I need to do is there?

[/quote]



Here is how I have mine setup:





To make your testing easier just try doing the update to one asset manually, meaning enter the URL along with the the query string into your browser to set if you can get it updating that way. Once you do just step backwards and see if anything else was causing it not to work. :slight_smile:

I have tested it on just one asset by entering the URL directly. It doesn't work if I use a dynamic parameter. If I set the metadata field to a constant value it works both by directly entering the URL and through your JS script. It is clearly falling over in receiving the dynamic parameter.


It seems so straightforward to add a dynamic parameter that I can't see where I might have gone wrong. I don't have to define it anywhere else before using it do I?

[quote]
I have tested it on just one asset by entering the URL directly. It doesn't work if I use a dynamic parameter. If I set the metadata field to a constant value it works both by directly entering the URL and through your JS script. It is clearly falling over in receiving the dynamic parameter.



It seems so straightforward to add a dynamic parameter that I can't see where I might have gone wrong. I don't have to define it anywhere else before using it do I?

[/quote]



What version are you on? I seem to remember in an older version that you had to have "Use Default" checked in order to get it working.

4.01


Checking Use Default doesn't help. I don't know if this is significant, but if I set a constant value but also include a dynamic parameter, it doesn't update the metadata to the constant value (or the dynamic parameter of course).

I got some advice directly from Squiz about this and it seems that this method of using triggers doesn't work for product assets.


I was advised to use the Javascript API instead, which initial testing shows is possible, though daunting given my rudimentary knowledge of Javascript.

I have had another go at this problem using the Javascript API and I have been able to make it work.


For the asset listing I used:


    
%asset_name%


And for the Javascript I used:

    
<script type="text/javascript">
  
setApiKey(8711594516); 
$(function() {

  $('.item').click(function() {

var id = $(this).find('.assetID').val();
var newVal = $(this).find('.val').val();

setMetadata(id,24452,newVal,function(data){
  $(this).addClass("done");
  }
);

  });//end
  
});//end
</script></pre>