pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
416 stars 643 forks source link

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

Open Nagarajan1605 opened 5 years ago

Nagarajan1605 commented 5 years ago
    <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.

srinubhumadi commented 4 years ago

Any update on this issue I am also facing the same issue after add data only alert is displaying but data is not adding to the list