0
function UpdateDocsDetails() {
  var def = jQuery.Deferred();
  var itemPayload = "";
  var restSource = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('DMSDocs')/Items(" + lastItem + ")";
  itemPayload = { "__metadata": { "type": "SP.Data.DMSDocsItem" }, "RequestID": _reqID};
  var dfd = jQuery.Deferred();
  jQuery.ajax(
    {
      url: restSource,
      method: "POST",
      contentType: "application/json;odata=verbose",
      data: JSON.stringify(itemPayload),
      headers:
      {
        "Accept": "application/json;odata=verbose",
        "X-RequestDigest": jQuery('#__REQUESTDIGEST').val(),
        "X-HTTP-Method": "MERGE",
        "If-Match": "*"
      },
      success: function (data) {
        // alert("Success");
        dfd.resolve(data);
      },
      error: function (err) {
        dfd.reject(err);
        // alert("Error:");
      }
    });
  return dfd.promise();
}

this function is need to update the lookup column RequestID

function SaveDeferred(action) {
    var dialog = bootbox.dialog({
      title: 'Saving.......',
      message: '<p>Saving... <i class="fa fa-spin fa-spinner"></i></p>',
      closeButton: false
    });
    var c = CheckForAttachment();
    if (c == true) {
      var p = createItem(action);
      p.done(function (res) {
        if (UpdateFlag == 0) {
          _reqID = res.get_id();
        }
        var d = UpdateDocsDetails();
        d.done(function (_reqID) {
          console.log('Item created successfully!');
          if (UpdateFlag == 0) {
            var _nextNo = GetNextNumber();
            _nextNo.done(function (result___nextNo) {
              console.log(result___nextNo);
              var Series = result___nextNo.d.results[0].Series;
              var StartingValue = result___nextNo.d.results[0].StartingValue;
              var LastUsedValue = parseInt(result___nextNo.d.results[0].LastUsedValue);
              if (LastUsedValue == 0) {
                LastUsedValue = LastUsedValue + 1;
              } else {
                LastUsedValue = LastUsedValue + 1;
              }
              var _update_Title = UpdateTitle(_reqID, Series, LastUsedValue);
              _update_Title.done(function (result__updated) {
                console.log(result__updated);
                var _udp_NoSeries = UpdateNextNumber(Series, LastUsedValue);
                _udp_NoSeries.done(function (result___udp_NoSeries) {
                  dialog.modal('hide');
                  var msg = "Your request Submitted successfully!!";
                  bootbox.alert(msg + " Your request No is " + result__updated, function () {
                    window.location.replace("/sites/" + siteName + "/SitePages/DMSApprovedRequests.aspx");
                  });
                });
                _udp_NoSeries.fail(function (result__udp_NoSeries) {
                  console.log(result__udp_NoSeries);
                });
                console.log("Your request sent successfully!! Your request No is " + result__updated);
              });
              _update_Title.fail(function (result__updated) {
                console.log(result__updated);
              });
            });
            _nextNo.fail(function (result___nextNo) {
              console.log(result___nextNo);
            });
          }
          else {
            dialog.modal('hide');
            bootbox.alert("Your request sent successfully!!", function () {
              window.location.replace("/sites/" + siteName + "/SitePages/DMSApprovedRequests.aspx");
            });
          }
        });
      });
      p.fail(function (ex, error) {
        console.log(ex + " " + error);
      });
    }
    else {
      dialog.modal('hide');
      return false;
    }
}

this function when item saved in SharePoint list but my Page is stuck on saving dialog after UpdateDocs Details() called but not going further to next number update in function

Your Answer

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

Browse other questions tagged or ask your own question.