Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

I need to update a hyperlink field using JavaScript

$
0
0

I have a requirement that I need to update a Hyperlink field in a list but the JavaScript code is not working. Any idea what is wrong with the code below?

All my alerts are working but my listitem does not get updated.

function UpdateAuditListitm(NextActionRecommendationTitle, NextActionRecId) {   
    // alert('Update Audit is called.');  
  var clientcontext = SP.ClientContext.get_current();          
  var web = clientcontext.get_web();          
  var lists = web.get_lists();     
  var myList = lists.getByTitle("Audit");  
   mylistItem = myList.getItemById(AuditId);       
   var urlDescription = "Recommendation " + NextActionRecommendationTitle
 alert('Description is: ');  alert(urlDescription); 
 var myNextActionUrl =  _spPageContextInfo.webAbsoluteUrl + "/sites/AAPMySite/SitePages/recommendation.aspx?recommendation=" + NextActionRecId; 
 alert(myNextActionUrl);
  var urlValue = new SP.FieldUrlValue();
  urlValue.set_url(myNextActionUrl);
  urlValue.set_description(urlDescription);
  mylistItem.set_item("NextActionDue_Link", urlValue);     
  mylistItem.update(); 
  clientContext.load(mylistItem);  
  clientContext.executeQueryAsync(  
     Function.createDelegate(this, this.onNextActionLinkSucceeded),   
     Function.createDelegate(this, this.onNextActionLinkFailed)  
   );  

}

function onNextActionLinkSucceeded() {

    alert('Next Action link updated!');
}

function onNextActionLinkFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Thanks


faye fouladi



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>