Javascript to move page from page library to document library

hi friends
my scenario is.
i have to move page from page library to another library using only javascript.
is it possible please help me.

my working code
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
var _ctx;
var _sourceFile;
var _destinationlibUrl;
var _destinationFile;
var targetListItem;
var itemId=10;
$(document).ready(function () {
$("#Archive1").on("click", function(){
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', CopyFile);
function CopyFile() {
//_ctx = new SP.ClientContext(siteUrl);
_ctx = new SP.ClientContext.get_current();
// Get the Web site that is associated with the client context.
this.web = _ctx.get_web();
_ctx.load(this.web);
// Returns the list with the specified title from the collection.
this.sourceList = this.web.get_lists().getByTitle('Pages');
_ctx.load(this.sourceList);
// Get the list items being selected.
//var selectedDocuments = SP.ListOperation.Selection.getSelectedItems(_ctx);
//this.currentItem = sourceList.getItemById(selectedDocuments[0].id);
this.currentItem = sourceList.getItemById(itemId);
_ctx.load(this.currentItem);
// Get the file that is represented by the item from a document library.
_sourceFile = this.currentItem.get_file();
_ctx.load(_sourceFile);
_ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
// Delegate that is called when the query completes successfully.
function onQuerySucceeded(sender, args) {
if (_sourceFile != null) {
_destinationlibUrl = web.get_serverRelativeUrl() +'/PageArchive/' + _sourceFile.get_name();
alert('Now moving to: ' + _destinationlibUrl);
//_sourceFile.moveTo(_destinationlibUrl, 1);
_sourceFile.copyTo(_destinationlibUrl, 1);
notifyId = SP.UI.Notify.addNotification('Moving file ' + _sourceFile.get_serverRelativeUrl() + ' to ' + _destinationlibUrl, true);
_ctx.executeQueryAsync(
function (sender, args) {
SP.UI.Notify.removeNotification(notifyId);
SP.UI.Notify.addNotification('File copied successfully', true);
// window.location = web.get_serverRelativeUrl();
function (sender, args) {
SP.UI.Notify.addNotification('Error copying file', false);
SP.UI.Notify.removeNotification(notifyId);
alert('Error occured: ' + args.get_message());
// Delegate that is called when the destination file checkout completes successfully.
// Delegate that is called when server operation is completed with errors.
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
</script>

Similar Messages

  • HT204053 how do i move page and numbers documents from one icloud login to another?

    how do i move page and numbers documents from one icloud login to another?
    I had to change my email address whcih meant new apple login.
    I have a number of docs in iwork/pages and iwork/numbers.  How do I transfer them to my new login?

    There's a couple of ways but my tip backing up your documents in the cloud is as good as any.

  • How do I move pictures from one library to another?

    How do I move pictures from one library to another?

    For just a few export them out of Library A via the File ➙ Export ➙ File Export menu option with Kind = Original and import them into Library B.
    However, this will not include any edits or metadata (keywords, titles, etc.) that you've added.
    To get the original image, any edits and all metadata, keywords, titles, descriptions, places, etc., you'll need the paid version of  iPhoto Library Manager.  It can copy albums or events from one library to another and keep those items I mentioned earlier with the photos.
    OT

  • How do I move files from Event Library to Project Library?

    How do I move Files from Event Library to Project Library? I tried drop and drag, that didn't work. I am new to Apple. I have always had a windows box b4 this. If anyone can help, please do. Thanks
    Alain

    welcome argardner to the  boards..
    you're missing the concept of iM .. you don't move 'files' from Event to Project Library.. Events is the big box of all your imported clips; now, from that box of bricks, you drag the clips into all kind of projects.. you can 're-use' the same clip again'n again in many projects.. you can use all clips of all Events in one Project.. or all clips of one Event in two projects.. or..
    spend some time here:
    http://www.apple.com/ilife/tutorials/#imovie
    http://manuals.info.apple.com/en/iMovie08_GettingStarted.pdf
    the concept of Events & Projects, Clips and Libraries is at first glance very different to 'normal' editing apps, but you'll get convenient to it within minutes..

  • How do i move photos from photo library to camera roll

    how do i move photos from photo library to camera roll on ipod touch 4th generation

    I also had a similar problem with "photo library" and wondered how to do about copying my photos there to my computer. I was delighted when i succeeded moving my photos from my iphone4s "Photo library" to my "camera roll".
    I could do it using 3 apps: 1) fileExplorer 2) fileapp 3) dropbox
    Downloading these apps on my iphone devide and then Using 1) I was able to see my albums in "photolibrary" and open it in either 2) or 3). Opening it up in 2) fileapp, will give you the option to save in "camera roll" with the top right hand corner button. 
    After saving it in camera roll, I will be able to easily copy them out from camera roll from DCIM folder onto your computer.
    I am not a comp savvy person, and I managed.

  • Move music from itunes library to ipad?

    move music from itunes library to ipad?

    You need a third party app in order to do that. Here is one app that will do it.
    http://www.wideanglesoftware.com/touchcopy/

  • Move Photos from one Library to another

    How can I move pictures from one library to another in Iphoto 11 ?

    1. Export from one, import to the other. Though you will not get all the versions if you do this. You also need to be sure to sue the options in the Expor dialogue to write all the metadata to the files or that won't come over. Note there is no way to export Faces data.
    2. Use iPhoto Library Manager to move the files and all versions and all metadata - including Faces - between libraries. However this hasn't been fully updated for iPhoto 11 so you'll need to wait a few days.
    Regards
    TD

  • Running iTunes on a PC.  Can't move music from my library to my iPhone.  What settings am I missing?

    My shuffle finally died.  Tried to move music from my library to my iPhone 5s but can't.  Got to be missing a setting.  What am i missing?

    Music is not moved, it is synced.
    What, if any, errors are occurring when attempting to sync?

  • How to move photos from one library to another?

    Hi,
    I currently have 2 libraries and I want to move photos from one library into the other.
    How do I have to proceed?
    Thx
    A

    We're thinking of adding a library copy feature soon.  Hoping you can share some info here to help us understand how this might best work fo you.   Here's a few questions I have:
    - What do you use the 2 libraries for?
      - Why do you want to copy?
      - Do you have albums, favorites, and comments associated with the photos?  Do you want them copied?
    Anything else that you are hoping to accomplish here?
    Thanks in advance,
    Peter

  • I just updated my iphone to ios 7 and updated itunes to 11.1.  Yesterday I noticed I couldn't move music from my library to my iphone.  Today I noticed that most of the music on my iphone is gone.  What do I do?

    I  just updated my iphone to ios 7 and updated itunes to 11.1.  Yesterday I  noticed I couldn't move music from my library to my iphone.  Today I  noticed that most of the music on my iphone is gone.  What do I do?

    I don't see how the AAC Version thing really applies here - the issue seems to be with
    the time it takes for "Preparing to Update" to run when adding new songs and
    the fact that a bunch of songs can get temporarily deleted from your phone, then need to be recopied over.
    I should also add that I'm using iTunes for Mac (OS 10.6).
    And Linda0410, if you view your phone's library in iTunes on your computer while it's copying, you should be able to see a bunch of grayed out songs, and there will be a little indicator on the left hand side of each song that's currently being copied.

  • I cannot move songs from my library to my iphone

    I cannot move songs from my library (CD's that I own) on my laptop to my iphone

    They are not moved, they are synced.
    What if anything happens when trying to sync content to the device?
    Is it actually selected to sync or are you trying to manually manage content on the device?

  • HT1229 How do I move photos from iphoto library to my desktop

    How do I move photos from iphoto library to my desktop

    This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.

  • HT1535 I got family guy: its a trap! with a digital copy to put on my ipod 4th gen, I tryed to move it from my library to my ipod and when it finally looks like it is going to work it says that it cant be moved to my ipod because it will not play on my ip

    I got family guy: its a trap! with a digital copy to put on my ipod 4th gen, I tryed to move it from my library to my ipod and when it finally looks like it is going to work it says that it cant be moved to my ipod because it will not play on my ipod. Help please !!!!!!!

    If you go to Settings do you see an entry for the Nike app? There is no way to delete or hide that app?
    Have you tired using the Spotlight search? Maybe you just can't find it.
    Next would be to restore a gain. First from backup then next to factory settings/new iPod.
    The Nike app you can download/install
    Nike+ Running for iPhone 3GS, iPhone 4, iPhone 4S, iPhone 5, iPod touch (3rd generation), iPod touch (4th generation), iPod touch (5th generation) and iPad on the iTunes App Store
    Does work on the iPOd. You just do not get all the information that GPS/cellular connection can get. You will still be able to get distance/footstrikes like the installed app an you do not need the shoe sensor.. It uses the built-in sensors on the iPod

  • How do I move photos from one library to another?

    I have moved my 34gig iphoto library from my MBP to an external drive. I have now created a second library on the MBP with the intention of keeping just a smaller selection of my photos in this ready to edit.
    Is there an easy way of importing photos from the old library on the external drive to the new one? Do they link up in any way, or, will I need to export a selection from the old library to a new folder on the desktop and then import from there?

    To move all the versions, metadata and photos from one Library to another use iPhoto Library Manager.
    Exporting from one and then importing to another will not get all the metadata (Faces, for instance) nor will it get the versions.
    Another way to achieve what you seem to want to do:
    1. Quit iPhoto.
    2. Copy the iPhoto Library from your Pictures Folder to the external drive.
    Now you have two full copies of the Library. To choose between them: Hold down the option (or alt) key key and launch iPhoto. From the resulting menu select 'Choose Library'
    3. On the Internal Library, remove the pics you don't want with you all the time.
    Now you have one full library on the external and another smaller sub-set on the Internal.
    A couple of comments:
    a. The external disk needs to be formatted Mac OS Extended (Journaled)
    b: When you're removing the unwanted pics from the Internal Library you need to delete them in batches of about 100 or so. Trashing more at one time can cause problems with the database.

  • How do I move pictures from iphoto library to my desktop so I can these use them to sell on ebay?

    I recently moved pictures from my ipad to my iphoto library on my Macbook Pro computer. I want to now use these photos to sell on EBay. What are the steps I need to do to move these from one place to the other. This needs to be in laymans terms as my husband and I are new to this. Thanks for help.

    Put the photos in an iPhoto album.  Use the File ➙ Export ➙ File export menu option and export them to a folder on the Desktop.  From there you can upload them to Ebay via your browser.
    OT

Maybe you are looking for

  • Problem in Data transfer from view to Model

    Hi I am displaying MARC data in  BSP by taking Matnr as input on view.I am fetching the data in MODEL. But, when I enter the value for MATNR in view , it is not getting transferd to MODEL. So, data is not coming as MATNR value is empty in model. But,

  • A problem about loadMovie

    The problem pic's address: http://s2.album.sina.com.cn/pic/55aee59a02001291 (please ctrl+c the URL ) In the pic,the B.swf has a label,the label's position is random. Then,the A.swf has a MovieClip named Mc1,and Mc1 loadMovie B.swf. We can see,the Lab

  • Adobe acrobat dc dead links

    On the new update adobe acrobat dc the sign in link is inactive. What I mean by that is when I touch "sign in" nothing happens. The link is dead.

  • Can you print direct to printer?

    As the subject line ask "Can you print direct to printer?" instead of to the screen.

  • Some of my text turns up as images, why is this?

    When I publish my site I cannot select a lot of the text in different places on my site, it's all png files. Whats going on?