admin管理员组

文章数量:1123591

I am new to the topic of SharePoint access / JavaScript and a bit overwhelmed. I have a SharePoint list that I would like to fill with entries using JavaScript. The list only has the title column at the moment

I have a small test script that I would like to extend with an input field, the content of which is then stored in the list. What do I have to add to it to fill the list?


<body>
    <h1>Das ist Ein Test. Anscheinend hat es geklappt.</h1>
    <button onclick="closePage()">Bestätigen</button>
</body>
<script>
var loc = window.location.href;
const urlParams = new URLSearchParams(loc);
var tableDisplayName = urlParams.get("tableDisplayName");
var tablePathName = urlParams.get("tablePathName");
var id = urlParams.get("id");
var action = urlParams.get("action");
var customFields = null;
if(loc.indexOf("customfields") != -1) {
    customFields = JSON.parse(urlParams.get("customfields"));
}

SP.SOD.executeOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");

function retrieveListItems() {
    alert("Script loaded successfully!"); // Popup-Fenster zum Testen
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

function closePage() {
    window.close();
}
</script>

I am new to the topic of SharePoint access / JavaScript and a bit overwhelmed. I have a SharePoint list that I would like to fill with entries using JavaScript. The list only has the title column at the moment

I have a small test script that I would like to extend with an input field, the content of which is then stored in the list. What do I have to add to it to fill the list?


<body>
    <h1>Das ist Ein Test. Anscheinend hat es geklappt.</h1>
    <button onclick="closePage()">Bestätigen</button>
</body>
<script>
var loc = window.location.href;
const urlParams = new URLSearchParams(loc);
var tableDisplayName = urlParams.get("tableDisplayName");
var tablePathName = urlParams.get("tablePathName");
var id = urlParams.get("id");
var action = urlParams.get("action");
var customFields = null;
if(loc.indexOf("customfields") != -1) {
    customFields = JSON.parse(urlParams.get("customfields"));
}

SP.SOD.executeOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");

function retrieveListItems() {
    alert("Script loaded successfully!"); // Popup-Fenster zum Testen
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

function closePage() {
    window.close();
}
</script>
Share Improve this question asked 22 hours ago MiriMiri 1 New contributor Miri is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

You will need to utilize a rest api call to post the data you'd like to the SharePoint list. https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-the-sharepoint-javascript-apis-to-work-with-sharepoint-data

本文标签: htmlAdding Entries to SharePoint List Using JavaScriptStack Overflow