Some times, we need to modify the Fatwire Flex Content Definitions, that have been already created.

Say for example, there are thousands of Flex Assets, created using a Flex Content Definition. I would wish to remove / add few attributes to the content definition. I’ve done it.

Now, how the new attributes will reflect in the existing thousands of assets?

Simple answer: Just edit and save the assets. The new attributes will be reflected in the existing assets as well.

This is okay, if there are assets in tens, or around that. But, there will be thousands of assets, in reality. We can’t go and edit all the assets which are there in the system, as it is a lot of time taking process.

So, what to do now?

We can load all the assets through code, and use the tags like asset:load, asset:canedit, asset:save, etc to perform our job.

Here is a sample code, which loads and edits the asset, adding a value for the DESCRIPTION field.

//Checkout the asset. This is optional. But, suggestible to be used.

< asset : checkout type=”<%=ics.GetVar(“c”)%>” objectid='<%=ics.GetVar(“cid”)%>’>

 

//Load the asset.

< asset : load name=”SampleAsset” type='<%=ics.GetVar(“cid”)%>’ objectid='<%=ics.GetVar(“cid”)%>’ editable=”true”  >

//Scatter the asset’s attributes.

<asset:scatter name=”SampleAsset” prefix=”Sample“/>

//Set the new value

< ics:setvar name=”Sample:description” value=”THIS IS NEW DESCRIPTION” />

//Gather all the variables
<asset:gather name=”SampleAsset” prefix=”Sample” />

//Save the asset to the database
<asset:save name=”SampleAsset” />

//Checkin the asset.
<asset:checkin name=”SampleAsset” />

Now, INSPECT the assets from the Admin UI. You will find them updated.

Advertisements
Comments
  1. Sushanth Reddy says:

    I doubt if there are some syntax issues in Check out and Asset load code snippets.. Thanks!

    • KK says:

      heyy.. thanks for the quick update… yes the syntax was chopped off due to some problem, which i didnt notice. thanks for visiting my site… keep visiting..

      • srangach says:

        KK a quick question

        Here description is the new attribute which is added to the content definition right ??? hope i am correct. Value you have given as “THIS IS NEW DESCRPTION..” so what exactly is the value – the actual description or the label which we see on the ADV UI when editing an asset ????

  2. Sushanth Reddy says:

    Hi srangach,
    Let me give you an answer, before KK could come back & approve this, to make it a ‘static final’ answer 😉
    Your first question: Yes, in the above example, the new attribute is added to content definition. In general, you could add new attributes in either of the existing definitions.
    Second question : “THIS IS NEW DESCRIPTION” is an attribute value and NOT display name of the attribute.

  3. srangach says:

    Hi Sushanth ,

    Thanks for the reply. Ok from your answer i can understand that the default value for this attribute is “THIS IS …. “when you open the assets of this kind of definition… Right???

    • Sushanth Reddy says:

      Hi dude.. yes, we have set the default value for ‘Desc.’ attr. in the above code. However, it will be a default value only for the existing assets & not for future assets. It is like a one time job.

  4. KK says:

    Suresh –

    The article which we discussed above is about editing an ALREADY CREATED ASSETS. The article describes how to edit those assets.

    In the above code, we have given the VALUE as “THIS IS NEW DESCRIPTION”. This means, after executing this code, the new description VALUE (NOT LABEL) will be applied to those assets (which are loaded through asset:load). Description here means the SYSTEM ATTRIBUTE “DESCRIPTION”.

    Just for sample, I’ve taken that attribute.

    And like Sushanth said, it is the VALUE, and NOT the DISPLAY LABEL.

  5. Kazi says:

    Hi,
    I have been through the process of editing an asset programatically in java.
    Could you please show how to create a new dimension and add it to an asset ?

    Thanks in advance,
    Kazi.

    • Kazi says:

      This code in java worked perfectly..

      // adding dimension Parent
      DimensionValue dimParentval = new DimensionValue();
      dimParentval.setAssettype(“Product_P”);
      dimParentval.setId(Long.valueOf(“1114083739046”));// FSII Audio (original)
      dimParentval.setGroup(“Locale”);
      asset.getDimensionParents().add(dimParentval);

      // // adding dimension
      DimensionValue dval = new DimensionValue();
      dval.setAssettype(“Dimension”);
      dval.setId(Long.valueOf(“1154551493565”));//
      dval.setName(“de_DE”);
      dval.setGroup(“Locale”);
      asset.getDimensions().add(dval);

  6. Nirav Varma says:

    Hi,
    Can you tell if this will work for Flex assets too?? If not, do you have some code snippet for editing and saving flex assets at one go?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s