Retrieve URL value from column in CSOM Javascript RRS feed

  • Question

  • Hi,

    I have a custom column of type URL, which holds the URL in it.

    I am trying to access the value using CSOM Javascript. But I am getting as "[Object]"

    I have used the below code:

    function loadItems() {
        var clientcontext = new SP.ClientContext.get_current();
        var oweb = clientcontext.get_site().get_rootWeb();
        var olist = oweb.get_lists().getByTitle(TestLibrary);
        selCategory = $(".hdnlabelClass").val();     
        if (selCategory != "") {
            var query = new SP.CamlQuery();
    query.set_viewXml('<View><Some Query></View>');
            TestListItems = olist.getItems(query);
            clientcontext.executeQueryAsync(Function.createDelegate(this, this.RenderHtmlOnSuccess), Function.createDelegate(this, this.RenderHtmlOnFailure));
        else {
            alert("Set a valid Category");
    function RenderHtmlOnFailure(sender, args) {
     alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    function RenderHtmlOnSuccess() {
        var enumerator = this.TestListItems.getEnumerator();
        while (enumerator.moveNext()) {
            var currentItem = enumerator.get_current();
         var   imagePath = currentItem.get_item("testfilePreviewPath");

    In f12 for the variable imagePath for the item "currentItem.get_item("testfilePreviewPath")", i can see as :

    {...}             object
    $2_1 = "url"  string
    $3_1 = "url"     string

    The data is there is $2_1 and $3_1..

    How to fetch the URL value?


    Wednesday, January 21, 2015 6:51 AM


  • Hi,

    According to your description, my understanding is that you want to retrieve the url value from the field using JavaScript Client Object Model

    If you are using hyperlink field to hold the URL, There are two attributes called “url” and “description” in the field

    We can get the url value using get_url () method like below:

    function onRequestSucceeded(sender, args) 
         var enumerator = collListItem.getEnumerator();
          while (enumerator.moveNext()) {
        var currentItem = enumerator.get_current();
        var imagePath = currentItem.get_item("test");
        var test= imagePath.get_url();

    Best Regards

    Forum Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Jerry Guo
    TechNet Community Support

    • Proposed as answer by Shakir Jahir John Thursday, January 22, 2015 2:22 PM
    • Marked as answer by Eric Tao Friday, February 6, 2015 1:39 AM
    Thursday, January 22, 2015 8:20 AM