Add new item to antoher site list

rss

Posted by Sebastian Haugland - Apr 28 ’15 at 06:25

I have made a form in one list and in that form I would like to have a button where I can click to add an item (with predefined data) to another list in another site. Any suggestions to a script? (no user input)

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 8 months 29 days
    #1 by Dmitry Kozlov Apr 29 ’15 at 04:26

    Hi Sebastian,

    You can add an item to another list with the help of JavaScript by using CSOM (or REST) and our JS-framework to retrieve values from the current form's fields.

  • Sebastian Haugland
    Sebastian Haugland
    Member
    Member for: 4 years 2 months 27 days
    #2 by Sebastian Haugland Apr 29 ’15 at 05:44

    Thanks, but I have allready tried that  - gets no error, just not working - , is this only working in SP 2013? (I am on 2010).

    Could all functions be in the button script or do they have to be in the JS editor of the form? (only calling them from the button.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 8 months 29 days
    #3 by Dmitry Kozlov Apr 29 ’15 at 05:54

    [#2]: This approach works in SharePoint 2010 as well:

    https://msdn.microsoft.com/en-us/library/office/hh185011(v=office.14).aspx

    You can define functions globally in the general JavaScript editor of Forms Designer but you should use the following syntax:

    window.my_global_func = function() {
    
    }

    Next, you will be able to use this function in OnClick handlers:

    my_global_func();
Displaying 1 to 3 of 3 messages