Mostrando entradas con la etiqueta custom element. Mostrar todas las entradas
Mostrando entradas con la etiqueta custom element. Mostrar todas las entradas

5 sept 2011

Get metadata values from external service in a Custom Element Form

At my actual UCM project we are using some tables to store values of a metadata field.


We have already a custom service that performs a Query to the table to obtain that values, with this service we can show values of the DB table in our JSPX. (For more info on how to build this kind of components check Brian Bex Huff Book)


This is how our service returns the data:





Our customer ask us about the possibility of adding inside a Site Studio Contribution Form a custom element that shows in a combo the values of the table. After searching a bit I found Kyle's post really good and very similar to what I triying to do.


After modifying a bit the code, finally I have success, and my custom element performs this steps:
1- Executes a custom service
2- Obtain the data from XML Request via AJAX
3- Prints a combo with the data obtained.


There is the source code. (link)


For your purposes you will have to modify the next lines 36-41

var httpCgiPath = "http://" + document.location.hostname + "/cs/idcplg"; 
var myRset = "QueryResult";
var myIDField = "CT2_ID";
var myDescField = "CT2_DESC_EN";
var myFieldName = "custom-content-type-level-2";

Also should be modified the line 295 where is the URL of the service execution:



var requestUrl = httpCgiPath + "?IdcService=CUSTOM_CTN2&idN1=15&IsSoap=1";
loadXMLDoc(requestUrl, loadComboValues);



This is how it looks like: