0

I am trying to get hyperlink type of column named as "Important Link". without var liHtml5="<li>" + ($(this).attr("ows_Important_x0020_Link")).split(", ")[0]+"</li>"; other code works perfect. Please help. My SPservice code is as below:

$().SPServices({

            operation: "GetListItems",
            async: false,
            listName: "URL_List",
            CAMLQuery: "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='text'>"+ URL+ "</Value></Eq></Where></Query>",
            CAMLViewFields: "<ViewFields><FieldRef Name='Title'/></ViewFields>",
            completefunc: function (xData, Status)
            {
                    var itemCount = $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount");
                    alert(itemCount);
                    if(itemCount == 0)
                    {
                        //check if URL contains slash
                        var SlashTesing=URL.indexOf("/") != -1;   
                        alert(SlashTesing);

                        if(SlashTesing== true)
                        {
                            NewURL=URL.substring(0,URL.lastIndexOf("/"));
                            gofunction(NewURL); 
                        }
                       else
                       {
                            var liHtml2="<h2>"+"Sorry...we dont have this info "+"</h2>";
                            $("#tasksUL").append(liHtml2);
                        }
                    }
                else
                {
                    $(xData.responseXML).SPFilterNode("z:row").each(function() 
                    {
                        var text="<h2>"+"Showing information for this URL :"+URL+"</h2>";
                        var liHtml2="<li>" + $(this).attr("ows_Department") + "</h4>"+"</li>";
                        var liHtml3="<li>" + $(this).attr("ows_Team") + "</h4>"+"</li>";
                        var liHtml4="<li>" + $(this).attr("ows_PointOfContact")+ "</h4>"+"</li>";
                        var liHtml5="<li>" + ($(this).attr("ows_Important_x0020_Link")).split(", ")[0]+"</li>";


                        $("#tasksUL").append(text);
                        $("#tasksUL").append(liHtml2);
                        $("#tasksUL").append(liHtml3);
                        $("#tasksUL").append(liHtml4);
                        $("#tasksUL").append(liHtml5);

                    });
                }
            }
      });
1

It should just be:

var liHtml5= "<li>" + $(this).attr("ows_Important_x0020_Link").split(", ")[0] + "</li>";

You have extra parans in there.

If the column isn't required then you need to adapt your code:

var liHtml5 = "";
var link = $(this).attr("ows_Important_x0020_Link");
if (link.length){
 liHtml5= "<li>" + link.split(", ")[0] + "</li>";
 $("#tasksUL").append(liHtml5);
}
  • no...it does not work..! It look like that hyperlink column should be mandatory..! if its "required" column then it works like charm..! Any other way to get it worked.? – Rajeev K Jan 29 '15 at 14:53
  • If it isn't a required column, then you'd need to check for it. – Eric Alexander Jan 29 '15 at 14:58
  • edited answer to include another option – Eric Alexander Jan 29 '15 at 15:01
  • didnt help..!still same issue.! Do you see any any reason behind it.? Also I need to get person or group type of field...any thoughs? or should i post new thread? – Rajeev K Jan 29 '15 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.