Is it possible to create a new wiki page in wiki document library via Javascript Client Object Model?

I can find example using managed code, but I can get it translated to javascript code that I can use.
For example, this in managed code:
using
(SPSite
site = new
SPSite("http://sharepoint"))
  SPWeb
rootWeb = site.RootWeb;
  SPList
wiki = rootWeb.Lists["MyWiki"];
  SPFolder
rootFolder = wiki.RootFolder;
  SPFile
wikiPage = rootFolder.Files.Add(String.Format("{0}/{1}",
rootFolder, "My
Wiki Page.aspx"),
SPTemplateFileType.WikiPage);
When
I try to change that to javascript, I get a 'cannot find rootfolder'....
This
is what I have so far:
var pageName = "/digitalmerch/PageNotes/" + $('input[title="Page Name"]').val() + ".aspx";
//Get the current client context - creating the batch
context = SP.ClientContext.get_current(); 
site = context.get_web(); 
wiki = site.get_lists('PageNotes');
rootFolder = wiki.get_rootFolder();
wikiPage = rootFolder.get_files().AddTemplateFile(pageName), TemplateFileType.WikiPage);
context.load(wikiPage);
  context.executeQueryAsync(CreatePage2Succeeded, CreatePage2Failed);
But I obviously haven't translated this into javascript correctly -  the .get_rootFolder is undefined, and so the rootFolder.get_files().... is wrong as well.
Any hints?
Robin

Not specifically, this is on a standard list NewForm.aspx page - it should already be there. The code is in the PreSaveAction function, so by that time sp.js should be fully loaded on the page - I don't wait for it or use a ExecuteOrDelayUntilScriptLoaded(xxxx,"sp.js");
I know this is a syntax error somewhere. Also, all my objects are declared as global, so it shouldn't be anything like that..
And I see a typo above that I've fixed:
wikiPage = rootFolder.get_files().AddTemplateFile(pageName), TemplateFileType.WikiPage);
is actually
wikiPage = rootFolder.get_files().AddTemplateFile(pageName, TemplateFileType.WikiPage);
but that didn't help. I still get:
Object does not support get_rootFolder.
I've also tried splitting that part into the execution functions, making sure I load 'RootFolder' into the context, but that doesn't work either.
Robin

Similar Messages

  • Is it possible to create a new tab in 'Default settings for items' option?

    Hi everybody
    I am Raghu working in EBP2.0 & I have come across a difficlty and that is of creating a new tab and also the fields 'GL a/c', 'cost centre' or 'internal order' in this new tab.
    First of all please let me know whether is it possible to create a new tab for these fields.
    The purpose of this new tab is to default the cost centre and GL account with reference to shopping cart.
    As per current scenario, user has to enter the cost centre & the GL code as many times as the number of items in a shopping cart. I mean, if you have 10 items in your shopping cart then 10 times user has to input the cost centre & GL account. To avoid this we are required to add new tab so that per shopping cart we can enter the GL account & cost centre only once.
    Your immediate response would be very much apprecited.
    Regards
    Raghu

    hi Ram & Sreenivas
    Thanks for your immediate response.
    Ram, we can default GL a/c & cost centre in org structure since client wants to us to keep the option of entering these for every shopping cart.
    Sreenivas, I checked the 'copy to clipboard' option & its not there in EBP2 and I feel what you meant as cost centre tab is account assignment tab.
    Let me explain you more clearly about this requirement.
    Current Scenario
    1.Say a user has added 5 items to his SC.
    2.User has to enter cost centre & GL code 5 times & then he can order
    Required scenrio
    1.Say a user has added 5 items to his SC.
    2.As per the proposed functionality, user will click on 'Default settings for items' button. Three tabs will appear-->Basic data, Internal note & Delivery Address.
    We have to provide a new tab here where in user will default his GL & cost centre for this shopping cart & then order. This will help user to avoid entering GL & cost centre 5 times.
    For some reasons our client is not interested in defaulting this data.
    Please help in this regard if time permits.
    Thanks
    Raghu

  • Is it possible to create a new iCloud account and permanently transfer existing store purchases to it?

    Is it possible to create a new iCloud account and permanently transfer existing store purchases to it?

    Thank you for taking the time to try to answer my question. Let me phrase it slightly differently...
    I have a very old appleid that I've used for store purchases. I had a MobileMe account that was upgraded to iCloud. I'd like to merge the account data. I've been hoping Apple would come up with a solution to this, but they haven't yet.
    So, I'm wondering if I should make a new account of some sort and try to transfer data to it from both of the old accounts. It sounds like that can't work.
    I suppose then that the only thing to do is manually transfer all the information from the old MobileMe account to the primary appleid (which is some sort of iCloud + Store combination, no?). That might not be that hard to do, but it is somewhat high risk.

  • Is it possible to create a new Substitution String?

    Hi,
    my question is:
    Is it possible to create a new Substitution String?
    My problem is, that I need a side with three level of tabs.
    But in Apex there are only sides with two level of tabs.
    And when I create a new template to create a three level of tabs side i need a substitution string for the third tab level.
    Does anybody have an idea?
    Thank you,
    Tim

    Hello,
    No but you could build a list that looks just like your tabs and use that as your third level tabs just use one of the region positions to position the pseudo list tabs.
    Carl

  • Is there a possibility to create a new contact-group on an iPhone

    Actually I can't find a possibility to create a new contact-group as I do directly on an iMac. Any other function are similar in the area of iMac or iPhone.
    On the iPhone it's only possible to create a new contact (of person). Is this function not available?

    Hi Ralph9430
    Thank you very much for your quick answer.
    I know the Sync-function and it's active. But I wanna create a new group on my iPhone, not on my iMac. I couldn't find this function like a cross ("+") on my iPhone in the group-menu in Contacts. Do you see that problem?

  • Is there a way to create multiple New Tabs pages and name them?

    This feature is great but I would like to be able to create multiple new tabs pages and label them. This would be more useful than tabs groups that all load at once.

    No that is (currently) not possible.
    It will be possible in future Firefox version to specify the number of rows and columns.
    *[https://bugzilla.mozilla.org/show_bug.cgi?id=752841 bug 752841] - [New Tab Page] make the number of tabs adjustable
    <i>([https://bugzilla.mozilla.org/page.cgi?id=etiquette.html please do not comment in bug reports])</i>

  • Can you create a new folder and put several documents in it in Adobe?

    Can you create a new folder and put several documents in it in Adobe?

    Thank you for your help. Now I just want to expand on this a bit. To use the Applescript you have supplied me, how do I tell it to name the folder other than by date, and where to put it?
    Let me say, preferably, is it possible to make an action like this right-clickable? Instead of having to pick a script. Anything that slows this process down means I might as well do it all by hand. What I'd really love to do is this:
    Select a number of items. Right click to an action saying "create a new folder and put this items in it. Name the folder with the first item's name". Very simple and quick.
    Could this be accomplished? Through Automator? or something that can appear in the contextual menu? Folder actions?
    I'm just getting started with using these tools.

  • Creating a new Master Page for new SharePoint 365 Environment

    Hello,
    If you create a new Master Page for your 365 site collection should all the Promoted Links, List Headings, etc. (standard items that are in the OOO SP Master Page) still remain the 'Blue SP Color' or are you able to change these items in the Master
    Page as well?  If someone needs additional information on my question please let me know.
    Thank you in advance!
    Joanie

    Hi Joanie,
    use those article to build your master page for office 365
    http://rstagg.com/2013/04/17/office-365-branding-creating-a-custom-masterpage-for-your-office-365-public-facing-website/
    http://msdn.microsoft.com/en-us/library/jj822370.aspx
    Kind Regards,
    John Naguib
    Technical Consultant/Architect
    MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation
    Please remember to mark your question as answered if this solves your problem

  • Creating a new home page portlet in identity console in 11gR2

    Hi,
    I am in the process of creating a new home page portlet in self service UI. I created a new view controller project in j developer and created a bounded task flow and attached a jsff page to that. Now what are the next steps to be followed so that my custom page gets displayed with the other portlets when user clicks on Home in Identity console. I have some basic knowledge in ADF. Thanks in advance
    Regards,
    Durgaprasad
    Edited by: Durgaprasad on Dec 17, 2012 1:04 AM

    I am getting this error in the log..
    Element [MissedTerm] of resource catalog [catalogDefinition] has been excluded from the catalog due to error [null].
    My custom-catalog.xml file looks something like this
    <resource id="MissedTerm" name="MissedTerm" description="Hello World Taskflow Reference" repository="application.classpath" path="adflibcustomUI.jar/ADF_TaskFlow/WEB-INF+task-flow-definition.xml#task-flow-definition">
    - <attributes>
    <attribute value="coreDefault" attributeId="attr.background" isKey="false" />
    </attributes>
    </resource>
    Also i found some post similar to this issue but solution is not there
    Custom resource catalog

  • When i try to print a perfect bound for my 66-paged document it keeps creating two new blank pages

    When i try to print a perfect bound for my 66-paged document it keeps creating two new blank pages, how do i remove that 2 blank pages?

    That is essentially a 2 up format as shown.
    2 pages duplex will equate to 4 pages per sheet.
    Your document needs to be divisable by 4. Add two blank pages at the end of your document.
    Toggle "Print Blank Pages" from the Print Settings
    Remove the blanks after creating the booklet.

  • Creating a new first page for HAP_PDF_OFFLINE_FORM

    I've copied this to a z version and am trying to create a new first page. I've created a new subform and it prints correctly before the original information but I need the original info to start on the next page. Any help is appreciated, thanks.

    Mark subform which you want to move to next page, check tab Pagination (next to Layout, Object etc.), set "top of next page".
    Otto

  • Is it possible to create a ToC on Pages for IOS ?

    Hello
    Is it possible to create a ToC on Pages for IOS ?
    If its not possible its really a must have feature !
    Regards

    Creating a ToC with Pages for iOS doesn't seem possible. To let the good folks at Apple know how you feel, send your feedback to them:
    http://www.apple.com/feedback/

  • Recently when creating a new blank page, application freezes. have been using for years without a problem. Upgrade?

    recently when creating a new blank page, application freezes. have been using for years without a problem. Upgrade?

    When something that used to work stops doing so, the most likely culprit is corrupt preferences. Go to HD > Users > (your account) > Library > Preferences, delete the com.apple.iwork.pages.plist file & then restart Pages. In Finder, hold down the Option key while clicking on the Go menu & your user Library will appear about halfway down the list. Or you can choose Go to Folder from the Go menu in Finder & paste this line in the box:
    ~/Library/Preferences

  • How to create a new blank page in iStore module

    Hello ,
    How to go about creating a new blank page in a iStore minisite in Oracle EBS.
    Is there a template that can be used to create a page containing JSP tags needed by iStore.
    Thanks

    Hello ,
    How to go about creating a new blank page in a iStore minisite in Oracle EBS.
    Is there a template that can be used to create a page containing JSP tags needed by iStore.
    Thanks

  • Created a New Master Page

    I have created a new Master Page for my Sharepoint Online site and the design works great, Except when I try to add a new app.
    When I go to Site Contents > Add an app and do a search for eg a list it comes up blank, but when I do back to default master page they all appear perfectly. Is there something that I need to put into the new Master Page to allow for these Apps to appear?
    I followed this guide to create the Master Page
    http://www.microsofttechnology.net/2013/09/branding-sharepoint-2013-online-custom_19.html
    Any help appreciated.
    Thanks 

    Yes Since you have changed the master page those options would not be available. If you try this on a different site collection where you haven't set the master page it would work perfectly fine. Even if you have set a master page on a site and you create
    a sub site under that site collection then it wont be available to you because it comes with the default master page templates. The only way to achieve this is by resetting the default master page( or selecting the other template available
    in change the look of website option) or by hiring a SharePoint developer who can create a similar site content page and options of lists and libraries for you or inherit it from the master page code.
    If you find this information helpful then please propose this as an answer and vote.
    Thanks.
    Kind Regards,
    Ujjwal Patel
     |
    SharePoint Online Support Engineer,MCPD,MCTS,MCAD.
     

Maybe you are looking for