Best approcach on changing templates in a document library

Hello,
In a document library, I need to have hold two types of word documents - a) with one place for signing and b) with two places for signing. There are document templates for each one.
My approach to to use two content types, A1 for one sign and B2 for two signs. Each one will have its own document template and  an event receiver will fill the docx's fields  with data.
Now, there's a new specification: The user should be able to change from content type A1 to B2 and vice versa. The document should change accordingly.
My solution is an event receiver that will change the content type of the document, clear the contents of the existing docx, fill it up with the new document template's info and then fill ups the templates' fields.
Is there another approach, because this  doesn't look straightforward to me. I wish I could some how swap the docx and then fillup the data, The option of deleting the document and recreating it, is my  very last option.
Thank you
Christos

What you trying is better. check below
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/c99b4599-0864-48bb-9977-2dd2066fbbb8/sp-gugu-how-to-programmatically-change-a-list-items-contenttype-by-wss-webservice?forum=sharepointdevelopmentlegacy
http://stackoverflow.com/questions/4735572/could-not-change-the-content-type-of-a-document-list-item-in-a-document-library
// get the list item that you need to update (do this however is appropriate) SPListItem listItem; // get the list that the item is in SPList myList = listItem.ParentList; // Get the contnet type you want to change
it to // (Note: must already be associated with the pages library) SPContentType contentType = myList.ContentTypes["New Content Type Name"]; // Update the properties listItem["Content Type"] = contentType.Name; listItem["Content Type
ID"] = contentType.Id.ToString(); // Record the change without adding a new version number of changing the last modified by listItem.SystemUpdate();
Read more at
http://blog.brianfarnhill.com/2008/10/programmatically-changing-list-item-content-types#XSRrIpffUYMy7MAd.99
SPFile ofile = oweb.GetFile(oweb.Url + '/' + oDocSet.Item.Url + '/' + refName);
ofile.Item["ContentType"] = octype.Name;
ofile.Item["ContentTypeId"] = octype.Id;
ofile.Item.Update();
Or try
http://blog.brianfarnhill.com/2008/10/programmatically-changing-list-item-content-types

Similar Messages

  • How to restore word template from a document library

    Is there any possibilty to find the template directly in the file system? I have an older version of the file system, so if I would know the place where the templates would be saved, I will be able to get this template back.

    Document templates are stored in the default site resource location http://Server Name/Site/Document Library Name /Forms/Content Type Name/ or a resource list of library set up specifically the for document templates. The URL can be relative
    to a location on the site or the resource folder. For example, a URL relative to the site would be <Server Name>/Site/Library Name/Forms/Docname.doc, and a URL relative to the resource folder would be simply Docname.doc.
    Ref : https://support.office.com/en-us/article/Create-and-edit-content-types-3d5d45af-608d-4183-8d51-073095fe0312
    Regards, Khalil Kothia, PMP Blog : http://khalil-kothia.com Site : http://StayGreenAcademy.com/

  • Setup a template document in a SharePoint document library

    I created a template for a document library in SharePoint Online.  I configure it so when the user needs to open a new document the template opens.   It works if you go to Files\New Document, but if you click on the New Document link
    in the document library when you select word the default template opens.  How can I get the new document link in the document library to open the template document that I created?
    Thanks
    Judy

    Its simple.. Go to the document library template which you have created. Then go to its library settings. Then go to advanced settings and select allow management of content type to yes. Then try to click ok and scroll down to find the option add from
    existing site content types and then add your template which you have created and click ok. Once you have done that you will be able to see the option of that template when you click new. If you still don't get it then you can open a service ticket from the
    sharepoint portal and post your ticket number here and I will try to reach you as soon as I can to take care of the issue from there. If you find this information useful, then propose this as an answer and vote. Thanks.

  • Corrupt document gets created in document library with document template using createlistitem workflowaction in visual studio workflow for office 365 solution

    Hi,
    My requirement is to create a document library associated to a custom content type with a document template associated. Also I need to create a document based on the template in this document library when a new item is created in another list by taking the
    reference ID of that new Item , I need to create the document with the name appended by ID. I need to do all this deployment using WSP.
    I have created document library with document template associated to content type by following instructions in below stated blog :http://blogs.msdn.com/b/chaks/archive/2011/05/19/deploying-a-document-template-file-in-content-type-in-a-office365-sandboxed-solution.aspx
    This works perfect for me.
    However, there are few observations, when going to Document Library > Library Settings > Advanced Settings > Document Template section - doesnt shows the Edit template link. When tried to look at the value for the document template using view source
    , it is giving me /Lists/MyDocsListInstance/Forms/template.dotx instead of the actual template file uploaded.
    Ignoring the above observation, when I am trying to create a sandbox based workflow in visual studio to create document in document library when new item is created in another list, I provide the ContentTypeID as the ID associated with the document library
    with template. 
    It creates the corrupt document at end of workflow. 
    I have tried using .docx instead of .dotx files for workflow as per solution provided in some of the post but it isnt resolving my issue.
    Any help is much appreciated.
    Regards,
    Krutika

    OK, I am going to throw out a lot of ideas here so hopefully they get you closer to a diagnosis. Hang on :)
    Does it happen to work for some users but not others? If so, try logging in on the "good" computer with the "bad" username. This will tell you if the problem is related to the end-user's system. Also, once the user downloads a document
    successfully can they open and work on it in Word? Also, does the document library have any custom content types associated with it or does it just use 'Document'?
    I notice that there are other folks on the web that have run into this same problem and the similarity seems to be that they are either on SharePoint 2007 or have upgraded from 2007. Did this doc library start out as a 2007 library?
    What you might want to do is this: Make a site collection from scratch in 2013 (or find one that you know was created in 2013). Choose team site (or whatever you want) for the root web and set up the security the same way you have it on the malfunctioning
    library. Now, use windows explorer to copy and paste some of the documents to the new location. Be sure you recreate any needed content types. Now test it from the troubled user's computer.
    I'm thinking there may be something that is different about the library since it was migrated through various versions and updates since 2007. I've sometimes found that there can be problems (especially with user profiles but that's a different story) with
    things that go through this evolution.

  • Best way to change fund posted in an EBS document

    What is the best way to change the fund in one line item in a document produced when the electronic bank statment is processed? The bank charges fees that come through the statement and should post to a different fund then any other item such as checks, etc.
    I am trying a substitution but coming across the error Field COBL-KOSTL. does not exist in the screen SAPLKACB 0002.

    The error message that I was receiving...Field COBL-KOSTL. does not exist in the screen SAPLKACB 0002, was coming from function module EXIT_RFEBBU10_001 and include ZXF01U01. The programming code was attempting to default a cost center when the external transaction code = 661. The coding was removed and the default acct assignment cost center was added to the cost element master data. The substitution also worked correctly as it should.

  • The Create List Item workflow action does not work in document library with document template

    My end goal is more complex but below is a basic example of the issue I’m having that just simply does not work.
    I'm trying to use a site workflow to create an item in a document library that has a document template applied to it but the file that gets created by the workflow is corrupt and cannot be opened.
    I created a document library and edited the document template by adding some text to the header and changing it to a Word docx file instead of a Word dotx file. I tested the document template by clicking the files tab in the ribbon and then clicking new
    document which opens the document template in Word and allows me to edit and save the document back to SharePoint. Then I created a SharePoint 2013 site workflow in SharePoint Designer that contains a single Create List Item action, and that action creates
    an item in the document library with the name field statically defined. I published the workflow and then manually start it on the site. The workflow completes successfully and when I navigate to the document library the document has been created by the workflow.
    When I click on the document to open it in the Word Web App it throws the error pictured below and if I open it in the Word client application it just opens a blank document and not the correct document template.
    I also tried using a SharePoint 2010 workflow with pretty much the same results. Opening the document in Word Web App gives the same error as above and opening the document in the Word client application gives the error pictured below.
    Come on Microsoft creating a Word Document in a SharePoint Document Library from a SharePoint Workflow should just work! Is this a bug or does anyone have any ideas on what is causing the this issue?

    I had the same problem with corrupted document - this worked for me:
    1. Create a 2010 Workflow which creates the list element in a document library
    (you may start this workflow from your 2013 workflow if applicable)
    2. In the Create New List Item properties - make sure to set ContentTypeId to your content type
    ("Id for indholdstype" is Danish for "Contenttype ID")
    3. Your Content Type template should be a ".docx" file - NOT a ".dotx" file...!
    (I have always created my templates for content types as .dotx files - seems Microsoft wants us to use ordinary .docx files as template files for content types)
    Hope this helps you!

  • How do I change the name property of a file in a document library?

    I am trying to come up with an Event Receiver that will change the name property of an file when it is uploaded. For instance when a file is uploaded into a document Library, currently the Title is being generated (which is fine)...I want to be able to
    change the "Name" property from whatever it is, to match exactly what is in the "Title" property. Are there any sample codes/blogs out there that I can take a look at? Has anyone  had any experience doing this? It seems like something
    that should be straight forward, to change the "Name" property to match what is in the "Tilte" property.

    Hi,     
    You can try the code below which use the SPFile.MoveTo() function to change the name of the file.
    EventFiringEnabled = false;
    SPFile f = properties.ListItem.File;
    string spfileExt = new FileInfo(f.Name).Extension;
    f.MoveTo(properties.ListItem.ParentList.RootFolder.Url +
    "/" + properties.ListItem["Title"]+ "_new" + spfileExt);
    f.Update();
    EventFiringEnabled = true;
    Here is a similar thread for your reference:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/5cafb8e4-bb85-4147-9bda-4ab42a4d4817/sharepoint-2013-event-receiver-to-rename-files-not-working?forum=sharepointdevelopment
    A link about rename uploaded file using Event Receiver for your reference:
    http://paulgalvinsoldblog.wordpress.com/2008/01/25/quick-easy-rename-uploaded-file-using-sharepoint-object-model-via-an-event-receiver/
    Best regards
    Patrick Liang
    TechNet Community Support

  • Issue with site template that contains a document library with a lookup column to another list

    I have a document library called Proposals with a lookup column in the same site called Document Categories (multiple values allowed).  It points to a list called document categories.  I have several sample documents in the Proposal Library that
    contain valid document categories.  When I save the site as a template and instantiate it, everything is fine.  However, when I remove the sample documents from the Proposal library and rebuild the site template, I can't get the  template to
    create another site.  I get an error Unable To Open Lookup List.
    I don't understand why I can instantiate a site from the template when there's sample data, but not when the document library containing the lookup column is empty.
    Does SharePoint 2010 site template support lookup columns?
    Why would it make a difference if the library is empty?
    Thanks

    Hi,
    According to your description, my understanding is that the error occurred when you created a site from the template with no files in the document library.
    I tested the same scenario per your post, and I can create a site from the template with no files in the document library with no errors.
    To solve this issue, I recommend to verify the things below:
    Did you save the site as a template with Include Content checked? If yes, I recommend to test if it works when saving the site as a template with Include Content unchecked.
    Test the same scenario with a new site to narrow the issue scope.
    I also recommend to check the event log and ULS log to see if anything unexpected occurred.
    To check event log, click the Start button and type “Event Viewer” in the Search box.
    For SharePoint 2010, by default, ULS log is at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS.
    You can check the ULS log by the methods here:
    http://blogs.msdn.com/b/opal/archive/2009/12/22/uls-viewer-for-sharepoint-2010-troubleshooting.aspx
    http://msdn.microsoft.com/en-us/library/gg193966(v=office.14).aspx
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Sharepoint 2013, Document Library: Sharepoint is changing data in a single line of text column to ISO8601 after modifying other columns

    Hello there,
    basically, as the title says: We have a Document Library on a Sharepoint 2013. Attached to every document are multiple columns, the type for every column is 'Single line of text'.
    One column is called 'billing date' and has suitable data in it, e.g. 01.01.2015, 26.02.2015, 29.03.2015 an so on.
    Sometimes when someone is editing an other column of the same document the data in 'billing date' changes from 01.01.2015 to 2015-01-01T00:00:00Z for that document, seemingly randomly.
    Is there any way to configure or prevent this?
    Thanks in advance and kind regards,
    Michael

    Hi,
    From your description, my understanding is that SharePoint changes the format of date in single line.
    It is very strange issue. I try to reproduce your issue in my environment, but everything is OK.
    To solve your issue, I need to collect some information, please confirm these points below:
    When will the format of date change? Does it change immediately when you edit the document or after clicking save button?
    Does the issue occur in this document library or each one in your environment?
    Do you have some special configurations for this document library?
    In addition, could you provide a screenshot as below?
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • PDF is changing all my pdf documents into a word document - My boss sent me a pdf email through outlook and when I try to open it changes to a word document

    PDF is changing all my pdf documents into a word document - My boss sent me a pdf email through outlook and when I try to open it changes to a word document Help this is so frustrating

    Hi tinam74565130,
    That does sound frustrating! It sounds as though the filename associations have become confused on your computer. You should be able to reset that easily. Here are some instructions:
    Change which programs Windows uses by default - Windows Help
    How to change the default application for a file type | Macworld
    Please let us know how it goes.
    Best,
    Sara

  • How do you save work in  a template without changing template

    Using pages;How do you save work in  a template without changing template?

    When you open a template it is a copy of the template you get. You can write, add, delete or change what ever you like. It will not change anything in the template. When you save you have a document, not the template.

  • Mass Change fuctionality for Delivery Documents

    Hi all,
    I want to carry out a mass change for a field in the delivery document header.
    I know the transaction MASS is not catering for that.
    Is that any other standard  transaction to do a mass change in the delivery document header level, other than do it through a LSMW?
    Appreciate your help on this!
    Best regards,
    Anupa

    hi,
    MASS is not there.
    As per my knowledge
    BAPI_OUTB_DELIVERY_CHANGE - BAPI for Change to Outbound Delivery
    BAPI_INB_DELIVERY_SAVEREPLICA - Create Inbound Delivery
    RV_DELIVERY_CREATE - Create Delivery
    GN_DELIVERY_CREATE - Create an Outbound Delivery
    REGARDS,
    BALAJIA

  • Create Dynamic Document Library Templates

    I have the following scenario within our IT Org
    1. PMO office maintains a "Standards" library, to which they publish all standard templates that need to be used for Project Management.
    2. Each Project Manager would like to create a document library within their "project site" based on all the documents within "Standards" library.
    My question is, would it be possible to create a document library template whose contents are dynamically pulled from another library?
    Thanks.

    Hi ,
    Based on your description, my understanding is that each Project Manager
    creates document library with the same template, but what they need is that their document libraries have different content type with others.
    There isn’t an out of the box method to create document library templates dynamically.
    For your issue, I suggest each Project Manager create one document content type with the document template which they need, and add the content type into their document libraries. 
    Here is a similar case, you can use as a reference:
    http://social.technet.microsoft.com/Forums/en-US/7d238bb5-8af7-4027-97cf-b41f84bcdb5d/dynamically-create-document-templates-for-new-menu?forum=sharepointdevelopmentlegacy
    Best Regards, 
    Lisa Chen

  • Change default association with DOCUMENT class

    Hi
    Is it possible to change the default association of files in IFS with the DOCUMENT class to a subclass of DOCUMENT?
    I would like to make a subclass of DOCUMENT with additional attributes and, by default, associate ALL uploaded files with that subclass.
    If this is a setting in IFS manager, would someone be able to tell me what to change?
    Any help will be greatly appreciated.
    Thanks very much
    Hugo

    Hi,
    Yes, you have to associate the basic content type with the document library manually. You can refer to the following powershell:
    #Get site object and
    #specify name of the content type to look for in each library
    $site = Get-SPSite http://portal
    $lookForCT = "Sales Document"
    #Walk through each site in the site collection
    $site | Get-SPWeb -Limit all | ForEach-Object {
    write-host "Checking site:"$_.Title
    #Go through each document library in the site
    $_.Lists | where { $_.BaseTemplate -eq "DocumentLibrary" } | ForEach-Object {
    write-host "Checking list:"$_.Title
    $_.ContentTypesEnabled = $true
    #Check to see if the library contains the content type specified
    #at the start of the script
    if (($_.ContentTypes | where { $_.Name -eq $lookForCT }) -eq $null)
    write-host "No content type exists with the name" $lookForCT "on list" $_.Title
    else
    #Add site content types to the list
    $ctToAdd = $site.RootWeb.ContentTypes["HR Document"]
    $ct = $_.ContentTypes.Add($ctToAdd)
    write-host "Content type" $ct.Name "added to list" $_.Title
    $ctToAdd = $site.RootWeb.ContentTypes["IT Document"]
    $ct = $_.ContentTypes.Add($ctToAdd)
    write-host "Content type" $ct.Name "added to list" $_.Title
    $_.Update()
    #Dispose of the site object
    $site.Dispose()
    Reference:
    https://social.technet.microsoft.com/Forums/office/en-US/dc030cb6-5d99-47eb-9620-f3640f6d6b1b/powershell-script-enable-content-types-on-a-list-and-add-content-types?forum=sharepointadminprevious
    http://www.getinthesky.com/2014/11/add-contenttype-documents-sitecollection-using-powershell-sharepoint-2013/
    Best Regards,
    Eric
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Document Library Template with Permissions

    I need to create like more than 50 document libraries that contain the same folder structure and the same permissions its posible to create some kind of template that include permissions or some kind of automation?

    Hi,
    According to your post, my understanding is that you wanted to create more than 50 document libraries that contain the same folder structure and the same permissions.
    First, you need to create a document library that contain the folder structure and the special permissions.
    Then you need to make sure that you want to the libraries have same name or not.
    If the libraries have different names, we need to store the names in a database first.
    The solution is:
    storing the names in a text file database(or other location such as sql server)
    Receive the names from the database, and then create the libraries.
    Here is a similar thread for you to take a look at:
    http://social.msdn.microsoft.com/Forums/silverlight/en-US/2ed1c9ab-ace2-47a8-8556-553119a63583/bulk-create-records-or-document-libraries-via-powershell
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

Maybe you are looking for

  • Inital Value is not getting Saved

    Hi All, I have a radio group which has 3 radio buttons. *A *B *C When the page loads, I am setting the defaulting to the Radio Button C and setting an initial value XXX to a Messsage Text Input field. Till this point, it works perfectly fine. As per

  • Getting error in executing Select options

    Hi Experts, I am getting error in while executing select options in multiple selection range options in SCASEPS Transaction in PSRM module. suppose I am giving 500 records in a select options ( select single values tab) while executing i am getting m

  • Alter system set control_files

    when we use this command to multiplex the control files should we list all the current controls files as well the copied once If yes ,should i performe alter database backup controlfile to trace command ? Thanks in Advance

  • Facebook website not loading

    Ok, it was fine last week. Now It tried to load and eventually times out. However, ALL other websites load just fine. I have cleared history and cleared cookies. What else can I try? Also, my software ( moutnain lion) is up to date.

  • Too many contacts

    I have far more contacts in outlook than I want to keep on my iPhone. I would like to select a smaller group of contacts to sync, but iTunes wont let me change from all contacts to selected groups. What's the solution to this?