PNP.js添加项目功能在Sharepoint自定义中不起作用

时间:2019-04-28 06:32:57

标签: sharepoint

<script type="text/javascript" src="/sites/MP/SiteAssets/js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="/sites/MP/SiteAssets/js/fetch.js"></script>
    <script type="text/javascript" src="/sites/MP/SiteAssets/js/es6-promise.js"></script>
    <script type="text/javascript" src="/sites/MP/SiteAssets/js/pnp.min.js"></script>
    <script type="text/javascript" src="/sites/MP/SiteAssets/js/moment.js"></script>
    <script type="text/javascript" src="/sites/MP/SiteAssets/js/jquery-ui.js"></script>
    <script src="/sites/MP/SiteAssets/js/bootstrap.min.js"></script>
    <script src="/sites/MP/SiteAssets/js/bootstrap-datepicker.js"></script>
$("#btnPotentialTopic").click(function(){
debugger;
_documentTypes=$('input:radio[name=radio-group]:checked').parent().find('label').text();
_policyDocument=$('input:radio[name=radio-groupPolicy]:checked').parent().find('label').text();
_dateTopicEntered=$("#Date-Topic-Entered").val();
_potentialDocumentType=$("#PotentialDocType :selected").text();
_potentialTopicCreatedBy=$("#Potentialtopiccreatedby :selected").text();
_potentialTopicReadyforDevelopment=$('input:radio[name=radio-groupPolicyDevelopment]:checked').parent().find('label').text();
AddPotentialtopic();
});

function AddPotentialtopic(){
debugger;
$pnp.sp.web.lists.getByTitle("WOW").items.add({
DocType:_documentTypes,
PotentialTopic:_policyDocument,
TopicEnteredDate:_dateTopicEntered,
PotDocType:_potentialDocumentType,
PotentialtopicCreatedby:_potentialTopicCreatedBy,
PotTopicRdyForDev:_potentialTopicReadyforDevelopment

}).then(results=>{
alert("Your Data has been saved sucessfully");
console.log(results);
window.location.href="/sites/MP/SitePages/Report.aspx";
});

}

执行此代码后,它进入Addpotential主题函数中并执行pnp add item函数,但最终它不添加数据,也不进入结果部分。

控制台中也没有错误。你能告诉我可能是什么问题吗?

这不是SPFx。我将自定义页面放入共享点并执行此代码。

必须添加项目,它应该进入结果部分,页面应重定向到report.aspx

0 个答案:

没有答案