Javascript help to copy selected items from one list to another list on same site

Hello,
So I have a request that I am not sure how to handle. I have created a page with a list view webpart that displays all the items from one list.
The user is then supposed to select off multiple list items and click on a button (most likely a ribbon button) that will take the selected items and copy them to another list on the same SharePoint site.
I would like to do this with JavaScript, but have only found an example that copies library items to another library.

Hi KansaiKel,
According to your description, my understanding is that you want to copy selected list items to another list.
I suggest you can use JavaScript Client Object Model to achieve it.
Here is a code snippet for your reference:
<script type="text/javascript">
var context = SP.ClientContext.get_current();
var siteUrl = 'http://sp2013sps/sites/test';
var clientContext = new SP.ClientContext(siteUrl);
var web = context.get_web();
context.load(web);
var sourceId = SP.ListOperation.Selection.getSelectedList();
var source = web.get_lists().getById(sourceId);
var oList = context.get_web().get_lists().getByTitle('Copy');
context.load(oList);
var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
alert('debut');
for(var i in selectedItems)
var currentItem = source.getItemById(selectedItems[i].id);
context.load(currentItem);
context.executeQueryAsync(Function.createDelegate(this,test),Function.createDelegate(this,error));
function test(sender, args){
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', currentItem.get_item('Title'));
oListItem.update();
oList.update();
alert('done');
function error(sender, args){ alert('error');}""
</script>
Here is a detailed article for your reference:
Complete basic operations using JavaScript library code in SharePoint
Best Regards
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Zhengyu Guo
TechNet Community Support

Similar Messages

  • How To Copy Selected Music From One Library to Another?

    What is the best way to copy selected music from one library to another?
    I have a big and growing iTunes library -- 33,000 songs.
    A year ago I copied my library to my daughter's new iMac.  Now, a year later, I'm off to visit her and wonder how best to update her library.  In the past year I have added a number of items to my library and I'm sure she has done the same -- some might be the same but many will be different.
    How do I update her library with the new things I've added in the past year but not wipe out things she had added or duplicate when we each have a song?
    I can load any / all of my stuff on an external HD and take that to plug in to her computer.  Then what?  I want to avoid duplicates and make sure I get stuff like album artwork.
    I'm running iTune 10.4 on an iMac with OS X 10.6.8 -- my daughter will have the same iTunes and OS X once we update her software.
    Any advice would be great.
    Thanks

    If you're sharing the same Apple ID and all your songs are from the iTunes Store, it's easy:
    In iTunes on your computer, go to File->Preferences->Store and check the box next to MUSIC under AUTOMATIC DOWNLOADS.
    You should also read this article, the section titled TO DOWNLOAD PREVIOUSLY PURCHASED APPS, BOOKS, MUSIC, OR TV SHOWS TO YOUR COMPUTER:
    http://support.apple.com/kb/ht2519
    You could also use an rsync utility such as backuplist+ to perform a 2-way sync of the files in your two libraries while your computers are connected via FireWire with one of them in FireWire Target Disk Mode, or from your external hard drive with your daughter's computer and then to yours again. After that, you'll need to use iTunes on each computer to update its library with the new files:
    http://rdutoit.home.comcast.net/~rdutoit/pub/robsoft/pages/backup.html
    This last would also be the preferred method if you have authorized each other's computers for media purchased with each other's Apple IDs (i.e. you are not sharing the same Apple ID), or if you have music from sources other than the iTunes Store. Most likely, though, music from sources other than the iTunes Store would not be legal to copy in this way for this purpose, although there is probably no technical impediment.

  • Cs sdk: copying an item from one document to another

    is there a way to copy any item from one ai document to the other ?

    I'm not one for bumping old threads, but this problem is really giving me a headache...
    I'm having the same exact problem with copying groups from one document to another.  It doesn't seem to matter if it's a top-level group or not; any group that gets copied over results in the copied art not showing up in the layer list and gives errors when trying to click on it.
    If my source document looks like this:
    Layer 1
      <path 1_1>
      <path 1_2>
      Layer 2
        <path 2_1>
    If I DuplicateArt on the GetFirstArtOfLayer(Layer 1), Layer 1 gets copied into the new document, but it doesn't show up in the layer list and I get errors trying to click on any of the art.
    If I iterate over the children/siblings of Layer 1 and duplicate them all separately, <path 1_1> and <path 1_2> will show up correctly in the new layer list and are clickable, but Layer 2 will not, and clicking on <path 2_1> results in the error.
    At this point, the only solution I can think of is to recursively iterate over the source tree, manually creating the destination groups, and then copying the art work into them.
    Very frustrating!

  • Copy a mapping from one project to another project in same reepository.

    Hi All,
    I am using OWB 10GR2. I have two projects in this repository called dev_project and test_project. after completion of mappings development in dev_project, i want to move the mapping from dev_project to test_project. I was able to copy the mapping from dev_project to test_project.
    However, when i open the mapping in test_project project, I was able to see all mapping operators like sources, targets and all other operators. But filter operators, join operators and aggregator operators doesn't have its properties( means there are no filter condidtion, join condition).
    Please help me how to take those filter and join conditions also from dev_project to test_project.
    Thanks,
    pv

    There is a OWB bug 8267898 described as:
    COPYING MAPPING BETWEEN PROJECTS IN OWB LOOSES ALL THE OPERATOR PROPERTIES
    Try to apply patch:
    Patch 8289030 - PSE FOR BASE BUG 8267898 ON TOP OF 10.2.0.4 FOR WINDOWS 32BIT (215)

  • How do I copy selected files from one HD to another?

    To date, the only way I can do this is by copying the entire folder (or one file at a time). Does another program exist where I can copy groups of files rapidly?

    Select...Select All, Ctrl+C to copy the contents to the Clipboard, then in the other PSD image use Ctrl+V to paste the contents in on its own layer.
    Ken

  • How do I move selected photos from one event to another in iPhoto

    Using iPhoto 9.5.1, how to I move selected items from one event into another event. I do not wish to merge both events. Thanks.

    select the photos and flag them - then select the target event and use the add flagged photos to selected event command
    LN

  • Newbie Qs: Copying an outline from one application to another

    My apologies for accidentally posting this question twice!
    Hello,
    I want to copy an outline from one database to another, both on the same server. I know I can save the outline as a .otl file. But how do I actually copy this saved .otl file over to the other database? Sorry if this is a very basic question, complete newbie to Essbase. Thanks.
    ps: Is there another way of copying the outline over from one database to another?
    Edited by: Sam on Jun 27, 2010 1:48 PM

    Open the outline in Edit mode, and from File > Save As, Select "Essbase Server" tab. Navigate to database where you would like to save. If you have data inside the cube, it will give you options on what to do with the data.
    Hope this helps
    Thanks,
    Naveen Mikkilineni

  • Transfering items from one customer to another customer

    Hi Gurus,
    I have a requirement where we have to transfer the items from one customer to another customer in the same company code.
    We should also be clearing the items from the old customer as part of the transfer.
    Is there a way/transaction in ECC 6.0 to achieve this.
    This is not a one-time transfer and the business would like the option of doing it every period (on a case to case basis.) so any standard SAP (transaction) way of doing it would be preferred.
    Best Regards
    ew

    Dear,
    SAP provides you F-51 t code to post transaction with clearing.
    Select radio button transfer posting with clearing and press choose open item button. Give customer name whose blance is to transferred and account key as D. Press process open item and in next screen select line items which needs to be posted. Proceed further give other customer number with posting 01 and do the transfer. Hope it will help
    Regards

  • How to copy OVD configuration from one machine to another?

    We have two machines with OVD servers on them. The configurations should be identical from one machine to the other. We suspect there is a problem with the configuration on one of them. We need to know how to copy OVD configuration from one machine to another.
    Can you tell us how to do that?

    well i have this in mind which may help you.
    You would need to have a public ip address to the machine you have consoled to and on internet.
    Download the tftp software from below link.
    http://tftpd32.jounin.net/
    This software does not only act as the tftp server but also you can select the interface of you ethernet card as tftp server ip address.
    For ex if you are connected to a console and have a wireless card which is connected to internet also you connect you eth lan card to the eth or fast eth of the router.
    you can select which ever interface you want to act as the tftp server.
    you will need to add ip addres for you lan card and also config the router port as same if needed.

  • How to Copy the PLD from one database to another

    Dear Members,
       i have designed the  PLD for Purchase Order, i want to copy the particular PLD into another Database.
    i tried to copy the PLD from one database to another through copy express.. i copied the PLD sucessfully. But the problem is,it copies all PLD's from one database to another. i want only the Purchaseorder PLD has to be copied in to another database.any body can help me in this regard.
    With Regards,
    G.shankar Ganesh

    Hi,
    select * into A1 from RDOC where Author !='System'
    select *  into A2  from  RITM   where Doccode  in (select Doccode from A1 )
    select * from A1
    select * from A2
    sp_generate_inserts 'A1'
    sp_generate_inserts 'A2'
    you will get Insert scripts of A1 and A2 tables .After that You 'll  Replace A1 to RDOC and A2 to RITM.
    So that you can RUN this SQL srcipts any where (In any Database)
    but First u have to run sp_generate_inserts  Storeprocedure(from websites) .
    drop table A1,A2

  • (v 5.5) I can no longer copy and paste from one layer to another.

    I can no longer copy and paste from one layer to another in Illustrator (5.5). This started happening a few days ago. Restarting Illustrator and also my computer (Mac) didn't help. Any ideas?

    To clarify: If I select an object in layer 1 using command/c or command/x then select layer 2 and press command/v the object gets pasted back into layer 1 instead of layer 2. I've tried everything I can think of and can't correct the problem.
    Now the only way I can get an object from one layer to another is to drag it into another layer in the layers window.

  • Can I copy my iTunes from one Mac to another to a distant location?

    I have 2 homes one in NYC and the other in upstate NY. I have multiple Macs at both locations all using Snow Leopard and the latest version of iTunes(9). I only have 1 iTunes library I maintain at the upstate location and have to bring my iPod to the NYC location to play my music. Can I not copy my iTunes library to the NYC location using Home Sharing or using some other method? I often forget to bring my iPod and am left without my music.

    Prince Moe wrote:
    Hi
    Since I had a problem with my Mac's drive that suddenly failed (I am able to read ONLY), I replaced the internal HD with my emergency HD that I had backedup a few months before. I would like to know if there's a way to copy my settings from one mac to another? Is there a specific folder for all apps or do I have to find out each and every single file for each app?
    I need the settings for
    System (view, font, color,)
    Finder (view, etc)
    iTunes (that include all library, playlists, etc),
    Firefox (Bookmarks, settings & plug-ins),
    Safari (Bookmarks, settings & plug-ins),
    Address Book (contacts)
    Thuderbird (emails accounts, contacts, passwords, etc)
    Stickies (stickies on the dock - i have info on there unsaved)
    Filezilla (FTP infos)
    Would appreciate.
    Thnx.
    All that info is found in your user/library folder, I just did a 60 machine rollout and copied all those settings from user/library, just be forewarned that if you upgrade software those setting will not take on the machine, for example Adobe CS 3,4 will not usable by CS5.  let us know if you need more help.  Also make sure you copy most of your preferences in the user/library/prefences folder.
    Note: If you are using an identical backup with all apps and user settings, you can just copy all folders from user to your new home folder.  Remember that only if the image or backup is identical to your production OS.

  • Can i copy my settings from one mac to another?

    Hi
    Since I had a problem with my Mac's drive that suddenly failed (I am able to read ONLY), I replaced the internal HD with my emergency HD that I had backedup a few months before. I would like to know if there's a way to copy my settings from one mac to another? Is there a specific folder for all apps or do I have to find out each and every single file for each app?
    I need the settings for
    System (view, font, color,)
    Finder (view, etc)
    iTunes (that include all library, playlists, etc),
    Firefox (Bookmarks, settings & plug-ins),
    Safari (Bookmarks, settings & plug-ins),
    Address Book (contacts)
    Thuderbird (emails accounts, contacts, passwords, etc)
    Stickies (stickies on the dock - i have info on there unsaved)
    Filezilla (FTP infos)
    Would appreciate.
    Thnx.

    Prince Moe wrote:
    Hi
    Since I had a problem with my Mac's drive that suddenly failed (I am able to read ONLY), I replaced the internal HD with my emergency HD that I had backedup a few months before. I would like to know if there's a way to copy my settings from one mac to another? Is there a specific folder for all apps or do I have to find out each and every single file for each app?
    I need the settings for
    System (view, font, color,)
    Finder (view, etc)
    iTunes (that include all library, playlists, etc),
    Firefox (Bookmarks, settings & plug-ins),
    Safari (Bookmarks, settings & plug-ins),
    Address Book (contacts)
    Thuderbird (emails accounts, contacts, passwords, etc)
    Stickies (stickies on the dock - i have info on there unsaved)
    Filezilla (FTP infos)
    Would appreciate.
    Thnx.
    All that info is found in your user/library folder, I just did a 60 machine rollout and copied all those settings from user/library, just be forewarned that if you upgrade software those setting will not take on the machine, for example Adobe CS 3,4 will not usable by CS5.  let us know if you need more help.  Also make sure you copy most of your preferences in the user/library/prefences folder.
    Note: If you are using an identical backup with all apps and user settings, you can just copy all folders from user to your new home folder.  Remember that only if the image or backup is identical to your production OS.

  • I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?

    I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?  Any help will be appreciated.  Thank you.

    This should give you some good insight, I'd probably store them on an External HD on the old machine and then just drag and drop to the new machine.
    https://discussions.apple.com/docs/DOC-4141

  • How do I copy the style from one control to another?

    I need to programmatically copy the style from one graph to another. I'm currently using the importstyle and export style functions but I'd like to avoid that since: 1) I'm creating >100 of the same graphs in a scrolling window and execution time is a concern, and 2) it makes it harder to redistribute the application, and 3) you shouldn't have to import/export from disk just to copy a graph style.
    I noticed the copy constructor was disabled so you can't just create a new one from the original. I suppose I could iterate through all the styles and transfer them from the master graph to all the copies but is there an easier way to do that? If not, is there some sample code for that?
    I'm using MStudio 7.0 for C
    ++.
    Thanks,
    -Bob

    One way that you could do this would be to create a helper method that configures your graph rather than configuring it at design-time, then use that helper method to apply the settings to the new graphs that you create. However, this would only work if you wanted all graphs to be configured exactly the same way - this would not work if the settings of your master graph are changing at run-time and you want the new graphs to be configured with the current settings of the master graph.
    Another approach is to query each control for IPersistPropertyBag, create an IPropertyBag, pass the IPropertyBag to the master graph's IPersistPropertyBag:ave, then pass the IPropertyBag to the new graph's IPersistPropertyBag::Load implementation. I'm not aware of any implementations of IPropertyBag that are readily available for use in applications, so the tricky part is creating the IPropertyBag. Below is a very simple implementation of IPropertyBag that should be enough to get the job done for this example. First, add this to your stdafx.h:
    #include <atlbase.h>
    CComModule _Module;
    #include <atlcom.h>
    #include <atlcoll.h>
    Here's the simple IPropertyBag implementation:
    class ATL_NO_VTABLE CSimplePropertyBag :
    public CComObjectRootEx<CComSingleThreadModel>,
    public IPropertyBag
    private:
    CAtlMap<CComBSTR, CComVariant> m_propertyMap;
    public:
    BEGIN_COM_MAP(CSimplePropertyBag)
    COM_INTERFACE_ENTRY(IPropertyBag)
    END_COM_MAP()
    STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
    HRESULT hr = E_FAIL;
    if ((pszPropName == NULL) || (pVar == NULL))
    hr = E_POINTER;
    else
    if (SUCCEEDED(::VariantClear(pVar)))
    CComBSTR key = pszPropName;
    CComVariant value;
    if (!m_propertyMap.Lookup(key, value))
    hr = E_INVALIDARG;
    else
    if (SUCCEEDED(::VariantCopy(pVar, &value)))
    hr = S_OK;
    return hr;
    STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT* pVar)
    HRESULT hr = E_FAIL;
    if ((pszPropName == NULL) || (pVar == NULL))
    hr = E_POINTER;
    else
    m_propertyMap.SetAt(pszPropName, *pVar);
    hr = S_OK;
    return hr;
    Once you have a way to create an implementation of IPropertyBag, you can use IPropertyBag and IPersistPropertyBag to copy the settings from one control to another like this:
    void CopyGraphStyle(CNiGraph& source, CNiGraph& target)
    LPUNKNOWN pSourceUnknown = source.GetControlUnknown();
    LPUNKNOWN pTargetUnknown = target.GetControlUnknown();
    if ((pSourceUnknown != NULL) && (pTargetUnknown != NULL))
    CComQIPtr<IPersistPropertyBag> pSourcePersist(pSourceUnknown);
    CComQIPtr<IPersistPropertyBag> pTargetPersist(pTargetUnknown);
    if ((pSourcePersist != NULL) && (pTargetPersist != NULL))
    CComObject<CSimplePropertyBag>* pPropertyBag = 0;
    CComObject<CSimplePropertyBag>::CreateInstance(&pPropertyBag);
    if (pPropertyBag != NULL)
    CComQIPtr<IPropertyBag> spPropertyBag(pPropertyBag);
    if (spPropertyBag != NULL)
    if (SUCCEEDED(pSourcePersist->Save(spPropertyBag, FALSE, TRUE)))
    pTargetPersist->Load(spPropertyBag, NULL);
    (Note that "CreateInstan ce" above should be CreateInstance - a space gets added for some unknown reason after I click Submit.)
    Then you can use this CopyGraphStyle method to copy the settings of the master graph to the new graph. Hope this helps.
    - Elton

Maybe you are looking for

  • Is there an app that shows data usage at the top of screen on a iPhone

    I'm looking for an app that will run a data usage readout at the top of my iPhone 5 running in real time in the background Does anyone know of an app that does that?

  • Mail unexpectedly quits immediately with gmail imap

    I added my gmail account as imap to mail and now mail immediately quits when I open it... Now I can't get to my company mail because of this. I'd glady remove the gmail account since it appears to be the problem but can't because the app quits so sti

  • How to create an "exit widget" button on iAd producer.

    I am creating a widget for a children's book and would like to create a simple "exit button" (an X the reader can touch to close the widget). Thus far I have created the object, but i can't seem to find an an 'action' to associate with the "activated

  • Discount for trading in a old ipod touch for a new?

    is there any way i can get a discount by trading my old ipod touch in for a new one? i have the 1g and the only issues it has are from software upgrades (no-wifi) and hardware issues from bad manufacturing i guess is it possible to get a discount? be

  • Bi-7 bi content problem

    hai Friends,                 i have given business content activation task for fiar module,presently i am working on new implementation of bi7,but when activating business content in bi7 without any migration, i got 3.x flow for all my objects(cubes,