0

I am trying to create a button on SharePoint online classic page which will submit to a list. From there a flow will run.

Just a question I have found an example how this can execute. A few questions:

  • If I want the list to store the user information i.e who has pressed submit from there user profile, how can this be done the script
  • If I want the department to = data science how can this be done in the script?

The code example is here using an example called test list

<script type="text/javascript">

    $(document).ready(function () {

        $("#btnAdd").click(function () {
            var title = $("#txtTitle").val();
            AddListItem(title);
        });

    });

    function AddListItem(TitleField) {
        $().SPServices({
            operation: "UpdateListItems",
            async: false,
            batchCmd: "New",
            listName: "testlist",
            valuepairs: [["Title", TitleField]],
            completefunc: function (xData, Status) {
                alert("Data Saved! and Please check your List");
            }
        });
    }
</script>

I am just learning jquery so thanks!

1 Answer 1

0

You can achieve both these requirements:

  1. Whenever user clicks the submit button and create new item in list, SharePoint saves the name of user in Created By field against that item in list.

  2. If you want to track the name of users in separate list then you can create one new list and add new item in this list with user information after completion first item creation(in completefunc of the code you mentioned).

  3. To save the department in list, create one more field as department in your list and add one more value pair as department:'data science' in your valuepairs in your code.

Sources:

  1. CRUD Operation on List in SharePoint using JQuery and Spservices.

  2. Programmatically Save the items into SharePoint List using Spservices.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.