SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using CSOM (JavaScript) how do you get the URL and description fields from a Hyperlink field?

share|improve this question
    
Did you check the SPFieldUrlValue class? msdn.microsoft.com/en-us/library/ee552494(v=office.14).aspx – Vardhaman Deshpande Nov 17 '12 at 18:43
    
Yes - there's no complete example on there of how to use it. – Ryan Nov 17 '12 at 18:45
up vote 5 down vote accepted

Here is the working code:

var context = SP.ClientContext.get_current();
var myListItem = context.get_web().get_lists().getByTitle("ListName").getItemById(1);
context.load(myListItem);

context.executeQueryAsync(function(){

alert(myListItem.get_item("HyperLinkFieldName").get_description());
alert(myListItem.get_item("HyperLinkFieldName").get_url());

},function(sender,args){alert(args.get_message());});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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