SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

I created custom task display form and need to add 2 buttons to allow user approve and reject task in display mode. How can I set TaskOutcome value using JS?

My code is the following:

<td class="ms-toolbar" nowrap="nowrap" align="right">
<input id="buttonaccept" type="button" value="Утвердить" onclick="javascript:  somehow set the TaskOutcome value; {ddwrt:GenFireServerEvent('__commit;')}" />


share|improve this question
up vote 0 down vote accepted

If anyone will have the same question - you can do this via client object model supported by Microsoft. Here is a pice of code, which will help you:

  var QueryString = function () {
      // This function is anonymous, is executed immediately and 
      // the return value is assigned to QueryString!
      var query_string = {};
      var query =;
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
         // If first entry with this name
        if (typeof query_string[pair[0]] === "undefined") {
          query_string[pair[0]] = pair[1];
         // If second entry with this name
        } else if (typeof query_string[pair[0]] === "string") {
          var arr = [ query_string[pair[0]], pair[1] ];
          query_string[pair[0]] = arr;
         // If third or later entry with this name
        } else {
        return query_string;
    } ();

    function onQuerySucceeded() {

        //alert('Item updated!');

    function onQueryFailed(sender, args) {

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

    function updateItem(taskoutcome) {
       var clientContext = new SP.ClientContext.get_current();
       var oList = clientContext.get_web().get_lists().getByTitle('Задачи');
       this.oListItem = oList.getItemById(QueryString.ID);
       oListItem.set_item('TaskOutcome', taskoutcome);
       oListItem.set_item('Status', 'Завершена');

      var bodycontent = document.getElementById('bodytdid').innerHTML;
      oListItem.set_item('Body', bodycontent);

       clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

More details can found in

share|improve this answer

Your Answer


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.