Hello, we have an existing web service .ashx that works fine and creates a new external network directory (ex D:\Parent\NewDirectory) and
then returns the reference number for the newly created directory and I would like to use this web service call in a NewForm.aspx form, so when a New List item record is created, this web service call will create a new external directory name derived from
the “Title” of the new Sharepoint List record. However, I’m wondering if the following copied code is setup correctly for this kind of SP access based on some of the error messages I’m getting like: “The code on this page disabled back and forward caching”
and I’m not seeing the alert("FAILED") that I placed in the “).fail(function” method below, thanks for any suggestions or pointers!
<script type="text/javascript"> function PreSaveItem() { alert("1"); getData(); return true; } function getData() { var def = $.Deferred(); qaToken.getUserToken().done(function (eToken) { var d = {}; d['parentObjectID'] = 1875543; d['objectName'] = “NewDirectory”; d['objectTypeID'] = 1; $.ajax({ url:"http://apps.qa.corp/_services/webdocs/webdocs.ashx?action=object.CreateFolder", data: d, headers: { "X-QA-UserToken": eToken.userToken }, type:"POST" }).done(function(ajaxData) { def.resolve(ajaxData.d); }).fail(function (jqXHR, textStatus,errorThrown) { def.reject(jqXHR, textStatus,errorThrown); alert("FAILED"); }); }); return def.promise(); }
var qaToken = { userToken: "", userId: "", getUserToken: function () { var that = this; var def = $.Deferred(); if (that.userToken !== "") { def.resolve(that); return def.promise(); } $.ajax({ url:"http://[apps.qa.corp]/_Services/Authentication/UserToken.ashx", dataType: "jsonp" }).done(function (eToken) { that.userToken = eToken.userToken; that.userId = eToken.userId; def.resolve(that); }).fail(function (jqXHR, textStatus,errorThrown) { def.reject(jqXHR, textStatus,errorThrown); }); return def.promise(); } }</script>