Tuesday 26 May 2015

We can store the hyperlinks in the list by creating hyperlink data type, but we will be giving the URL while store into list along with the description. When you try to access the URL using CSOM we will get the URL instead of the description
To get the description using CSOM here we find the way to get it.

clientContext = new SP.ClientContext.get_current();
var vList = clientContext.get_web().get_lists().getByTitle("your listname");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘<view></view>’);
this.collListItem = vList.getItems(camlQuery);   
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this. success),Function.createDelegate(this, thisFailed));


function success(){
try{
var listItemEnumerator = collListItem.getEnumerator();
while(listItemEnumerator.moveNext())
{
var linkDesc = currentItem.get_item('URLfieldname').get_description();
var html = '<a href="'+Link+'">'+linkDesc+'</a>';
 }
You can show your hyperlink description now instead of link by append it to div or any way you want.


Cheers

0 comments:

Post a Comment