Search code examples
videocustom-fieldsbrightcove

Getting custom video fields in brightcove


I have created a call in my Media API to retrive my 'custom video field' called 'Product Name' and have been unsuccessful in retrieving it. In my Product Name column only pops up undefined. I have used ((n.customFields)?n.productname:'') in the snippet below to make the call.

function buildMAinVideoList() {

//Wipe out the old results
$("#tbData").empty();

console.log(oCurrentMainVideoList);
oCurrentVideoList = oCurrentMainVideoList;
// Display video count
document.getElementById('divVideoCount').innerHTML = oCurrentMainVideoList.length + " videos";
document.getElementById('nameCol').innerHTML = "Video Name";
//document.getElementById('headTitle').innerHTML = title;
document.getElementById('tdMeta').style.display  = "block";
document.getElementById('checkToggle').style.display  = "inline";
$("span[name=buttonRow]").show();
$(":button[name=delFromPlstButton]").hide();


//For each retrieved video, add a row to the table
var modDate = new Date();
$.each(oCurrentMainVideoList, function(i,n){
    modDate.setTime(n.lastModifiedDate);
    $("#tbData").append(
        "<tr style=\"cursor:pointer;\" id=\""+(i)+"\"> \
        <td>\
            <input type=\"checkbox\" value=\""+(i)+"\" id=\""+(i)+"\" onclick=\"checkCheck()\">\
        </td><td>"
            +n.name +
        "</td><td>"
            +(modDate.getMonth()+1)+"/"+modDate.getDate()+"/"+modDate.getFullYear()+"\
        </td><td>"
            +((n.customFields)?n.productname:'')+
        "</td></tr>"
    ).children("tr").bind('click', function(){
        showMetaData(this.id);

        })
});

I have made a similar call in my getPlaylist call and in the debugger it shows the custom field so I know that it is in the above code.


Solution

  • Your custom field will be returned as a child of customFields. Try:

    (n.customFields && n.customFields.productname)?n.customFields.productname:''