Nagarajan Elumalai

Nagarajan Elumalai

  • NA
  • 181
  • 23.6k

PNP.js add item function is not working in sharepoint custom

Apr 28 2019 1:27 AM
<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";
});**
}
After executing this code its coming inside the Addpotential topic function and execute the pnp add item function but finally its not adding the data and not coming inside the results section.
No error in console too. Could you please tell me what could be the issue.
This is not SPFx. I put the custom page in share point and executing this code.

Answers (1)