Updating metadata in a custom element in Site Studio

I was recently asked if it was possible to edit metadata on a Site Studio data file from an element instead of having to go to the Metadata tab specifically.  Users were finding it disorienting to move back and forth between the Elements and Metadata tabs when updating both content and metadata.

So I put together an example that places a metadata update form within a custom element. It uses a couple of AJAX calls to the server to get the current metadata values (DOC_INFO) and to update them (UPDATE_DOCINFO). The sample includes 3 fields; Title, Type, and Comments. 

It can be easily changed to add additional fields.  Or you could make the entire custom element to be one particular metadata field.  Much of the code in the sample has comments, so I won't go into detail here.  

One function I did find particularly useful was the ability to pull in the dID and dDocName of the data file into the custom element form.  The functions ElementAPI.GetFormProperty('dID') and ElementAPI.GetFormProperty('dDocName') were used in order to run the services against the content to pull and push the metadata information.

The sample can be downloaded here (right-click and save). Simply submit the file with the Web Site Object Type of 'Custom Element Form'.  Then create a new Custom Element that points to the form. I've tried it in both 10gR4 and 11g.   

Hopefully some other folks will find this helpful.


Fantastic idea, very helpful. Casual users rarely know the difference between elements and metadata.

Posted by guest on June 15, 2011 at 02:35 PM CDT #

How to include this "content info update form", in elements tab


Posted by Cassio on August 04, 2011 at 05:08 AM CDT #

When I try this, the element in contrib-mode just spits out a bunch of garbage. Starting with "include std_definitions" and ending with "include std_schema_footer"

I updated the htm code to reference my server, is there something else to adjust?

Posted by Bryan on November 28, 2011 at 06:46 AM CST #

Kyle, I checked in the html form and updated the code inside to reflect my server, but this doesn't work for me. The element in contrib mode just shows a bunch of IDOC markup. The form is there, but it doesn't work. Any ideas?

Posted by Bryan on November 29, 2011 at 09:01 AM CST #

I just realized IE saved the file as HTML. Oops. I checked it in as HCST and the form loads, but now I get "There was a problem retrieving the XML data." So close!

Posted by Bryan on November 29, 2011 at 09:23 AM CST #

Hey Bryan,

Sorry, I should have mentioned that you need to modify a URL defined in the .hcst file. Look for this in the file:

// change this variable to the HttpCgiPath for your server
var httpCgiPath = "http://ecm-base:16200/cs/idcplg";

I'm not sure why I don't have that value populated using IDOC script instead. But I'm guessing this might be why you are getting the XML data error. Try changing that and see if that helps.


Posted by Kyle Hatlestad on November 29, 2011 at 09:27 AM CST #

Thanks, I realized I had a type in there... so the XML loads and I see my Title and Comments in the metadata element. However, when I edit and hit the update button, it simply reloads the form with the old metadata values still in (and the metadata is not updated). Is there something I need to enable to allow the form to update the metadata for the content item?

Posted by Bryan on November 29, 2011 at 09:36 AM CST #

Hey Bryan,

First I would go to the Log files and see if there are any errors being thrown. Then what you can do is put in the line:


after that variable is set in the updateDocInfo function. That should display the entire URL that will perform the update. You can copy that URL and paste it in a new browser/tab to see what results you get running it manually.


Posted by Kyle Hatlestad on November 29, 2011 at 09:52 AM CST #

I'm really at a loss here. I added the alert(requestUrl); code you suggested after that variable is built up in the updateDocInfo function... but nothing is ever sent to the screen when I click the button. The alert() isn't firing for some reason. I checked the content server logs and there's nothing in there related to this. Argh.

Posted by Bryan on November 29, 2011 at 12:08 PM CST #

Ok, sorry to post so many messages... hopefully some benefits from this (in addition to me). I commented out TYPE, that seemed to be the issue at first. So, no it appears to try to submit, but the URL use for requestUrl produces the following error:

"Unable to update the content item information for 'TEST_STORY'. The authorization token is invalid. It has either expired or is not appropriate for the current request.
You may need to reload an earlier page in order to proceed."

At this point, I stare blankly at the screen. :)

Posted by Bryan on November 29, 2011 at 12:33 PM CST #

I figured it out... I had to include idcToken in the requestUrl.

Phew! Thanks for the tips.

Posted by Bryan on November 29, 2011 at 01:43 PM CST #

Hi Kyle and Bryan,

I have to change few metadata fields via JS when user click one of the button in my custom form. I don't have to load old values.
so I have commented out most of the code.
I'm getting the same issues as Bryan and his questions n answers helped me alot.
Bryan, What value you put for query string 'idcToken'. can you give me the sample URL that appears in your custom form.

Posted by MAK on December 27, 2011 at 05:47 PM CST #

Hi Kyle,

We can get the content id of data file in a custom element using ElementAPI.GetFormProperty('dDocName') but any idea how can we get the same content id in one of the static list element form?

It returns null if I use same function.


Posted by Tesh on February 27, 2013 at 06:42 AM CST #

Hi everybody, specially Kyle

This is an old topic but now I'm working in something similar and I've met some troubles.

I've developed an element form that updates a custom metadata (based on the input of the user in the element form).

I want to update the metadata automatically, i.e. with no user interaction (no button like the example above), so the request to the UPDATE_DOCINFO service is triggered on "Save an Close" button on the Site Studio complete editing form (during the Custom.GetData process).

The metadata is updated ok, but here's the problem: the metadata is updated on the current revision not on the new revision created when you save the editing form. So, in the end, I get an updated metadata but on the previous revision, not in the last revision (current), where the metadata is not modified.

I find it reasonable because I'm not modifying the metadata sent from the Site Studio form (popup) to Webcenter Content when pressing the "Save and Close" button (it's been done in a previous parallel way). Probably if I could I won't need even to call UPDATE_DOCINFO because the desirable value on the metadata would be saved when saving the whole content and generating a new revision (metadata + datafile).

I hope I've made my point...

So the question is: it's there any way of modify a metadata value sent to Webcenter Content on the "Save and Close" button action from a Custom Element Form? I mean something like the nonexistent ElementAPI.SetFormProperty('x_whatever')

Thank you very much in advance

Posted by Cutto on May 20, 2013 at 03:36 AM CDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Kyle Hatlestad is a Solution Architect in the WebCenter Architecture group (A-Team) who works with WebCenter Content and other products in the WebCenter & Fusion Middleware portfolios. The WebCenter A-Team blog can be found at: https://blogs.oracle.com/ ateam_webcenter/


« July 2016