Picture library and content types

Hey,
I have created a Picture library in SharePoint.
Now I want to add a custom content type to picture library.
SPSite oSite = new SPSite("http://
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["Picture"];
SPContentType oDocContentType = oWeb.AvailableContentTypes["Stefan Picture"];
oList.ContentTypesEnabled = true;
oList.ContentTypes.Add(oDocContentType);
oList.Update()
But this code adds 2 content types to the picture library (picture and Stefan picture). What I can do so only the content type Stefan Picture will be added to the document library?
Thanks for your help
Stefan

Thanks Samuel for your help.
When I delelte in the schema.XML the contenttype attribute and set
ContentTypesEnabled=false
then will be (after run the code
SPSite oSite = new SPSite("http://
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["Picture"];
SPContentType oDocContentType = oWeb.AvailableContentTypes["Stefan Picture"];
oList.ContentTypesEnabled = true;
oList.ContentTypes.Add(oDocContentType);
oList.Update()
in an event receiver) only one content type shows up in the new button.
Regards
Stefan

Similar Messages

  • Batch uploading to a document library with content types

    Hi,
    I have a document library with two content types. Now I need to upload documents to this document library. However, if I have large number of files, then uploading through web UI is a pain as metadata will not be attached. How should I automate it  from
    my computer using powershell without relying on Administrator to run the powershell script. Or is there any other way to do it without using powershell? or  can powershell be run remotely from an end user computer?
    Note I am using SharePoint 2010.

    Hi,
    According to your post, my understanding is that you want to butch upload files to document library with content types.
    There are two good tools in CodePlex which can batch upload files with content types, you can have a look at them.
    DocMetaMan : Bulk document Upload and MetaData (Taxonomy) Setter
    SharePoint Multiple File Upload Script
    There are some third-party tools which can achieve the same scenario, you can refer to it.
    http://sharepoint.stackexchange.com/questions/74694/uploading-multiple-files-with-metadata
    Thanks,
    Jason
    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]
    Jason Guo
    TechNet Community Support

  • Error after updating field and content type

    Hi,
    I have a feature with a custom list and content type.
    I changed one field type from Text to Note, and made the same change in my Schema.xml file.
    But after deploying I get an error when I visit my list.
    "The file name you specified could not be used.  It may be the name of an
    existing file or directory, or you may not have permission to access
    the file".
    I have several sites with the same list, and all gives the same error.
    What I understand from the ULS logs it can't find my schema file, but when I look at the 14 hive it is there.
    ULS
    Failed to open the file 'schema.xml'.
    Failed to retrieve the list schema for feature {4D3315CB-7F20-4DB3-9CB3-258AC110F9BC}, list template 21973; expected to find it at: "".
    Any ideas about how to fix this?
    The text expected to find it at: "" can be the problem as I have my schema file in a folder named Correspondence List.
    And in the 14 hive I find the schema at 14\TEMPLATE\FEATURES\my feature\Correspondence List\Schema.xml
    This is from my manifest file:
    <ElementManifest Location="Correspondence\Elements.xml" />
    <ElementManifest Location="Correspondence List\Elements.xml" />
    <ElementFile Location="Correspondence List\Schema.xml" />
    Any help are appriciated

    Hi,
    Any update?
    Best Regards
    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]

  • To search only images in a particular folder of picture library using content search webpart.

    I have Images library where i am storing images in different folders.I need my content search webpart to search and display images in a particular folder in Images Library.For ex: i need to if my Picture Library Name is 'Images' a folder inside that is
    'Travel' which is having some images.I need my content search webpart to pick images from 'Travel' folder only.Any pointers to this will be helpful.

    Hi,
    According to your post, my understanding is that you want to search images in a particular folder via content search web part.
    When we use the search crawl the items in the images library, it crawls the items and folder with the following URL.
    For folder: http://sp13/PublishingImages/Folder1.
    For Items:
    http://sp13/PublishingImages/Forms/DispForm.aspx?ID=itemID
    It not crawls the items as the path
    http://sp13/PublishingImages/Folder1/Item, then we could not use this path to retrieve the items in the folder.
    As a workaround, we can create a custom field in the image library, such as a choice type field named
    Folders(it contains the folder names), when we create a image, we set the folder name in this field.
    Note: we should new a managed property manually to match the Crawled property.
    Then we can use this field to filter the items in a particular folder as below, it works like a charm in  my environment.
    path:"http://sp13/PublishingImages"   Folders=Folder1
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Document Sets and Content Types

    Hi All,
    I am having trouble in getting the "document sets" content types applied as expected when I try to create a site based off custom template.
    Scenario:
    We have 8 document sets stored in a document library. This library is part of a site which we have saved as a template.
    E.g. of document sets is "Others", "Meetings" etc
    Each of these document sets have one or more content types associated with it.
    We are trying to create a site based off the saved site template using powershell.
    E.g. $web = New-SPWeb http://myserver/sites/mysite/subsite
    $web.ApplyWebTemplate("{GUID}#Name of Template")
    When we open the document sets in this newly created site, the content types seem to be coming all together rather than being associated with the specific document set.
    E.g. Clicking "New document" in the "others" document set would show up content types from "meeting" and all the remaining document sets present in that library.
    Interestingly, when I go to "Document Set" settings, I only see the content type of "Others" Document Set.
    Any idea why the "New document" dropdown for the document set is not behaving as expected?

    Hi Abhi,
    Based on your description, I did a test. In my testing, everything worked well.
    The steps are:
    Go to Site Actions->Site Settings->Site content types.
    Create a new content type, and select parent content type from Document Set Content Types, and Parent Content Type: Document Set
    Click ok
    Under Settings, click Document Set settings
    On the Allowed Content Type section, select some content types and add them
    Click OK
    Then repeat step2-6, and create another custom document set
    Open your library, and allow management of content types in advanced settings
    Add the two document sets into the library
    Check each document set, and each one had different content types
    Save the site as a template and include the content
    Create a new site based on the site template using PowerShell(the command was same with yours)
    After creating, check the document sets of the library in the new site, everything worked well.
    Please check your process as the above steps.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • XML Parser and Content-type/encoding problem

    I've write a little and simple XML parser and a simple "trasformer" that recive an XML file and an XSL one and return HTML, here is the code:
    public static String toHTML(Document doc, String xslSource){
            ByteArrayOutputStream testo = new ByteArrayOutputStream();
            try{
                DOMSource source = new DOMSource(doc);
                TransformerFactory tFactory = TransformerFactory.newInstance();
                System.out.println("----> " + xslSource);
                Transformer transformer = tFactory.newTransformer(new StreamSource(xslSource));
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
                transformer.setOutputProperty(OutputKeys.METHOD, "html");
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
             transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                transformer.transform(source, new StreamResult(testo));
            }catch(Exception ioe){
                System.out.println("2 XMLTool.toHTML " + new java.util.Date());
                System.out.println(ioe);        
            return testo.toString();
        }the problem is that I would like to put the HTML code its return into a JEditorPane; now I'm trying with this code:
    JEditorPane jep1 = new JEditorPane();
    jep1.setContentType("text/html");
    jep1.setText(v);
    // 'v' is the string returned by the code posted up (the XML/XSL transformer)but I can't see anything in my JEditorPane.
    I think that the problem is this line of code that the transformer add automaticaly ad HTML code:
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">Infact if I try to delete this line from the code I can see what I want but is'n good delete a line of code without understend where is the problem.
    So, can anyone help me?

    good.
    when u set ur output properties to html , transformer
    searches for all entity references and converts accordingly.
    if u r using xalan these files will be used for conversion of
    Character entity references for markup-significant
    output_html.properties
    (this should be in templates package)
    and HTMLEntities.res(should be in serialize package)
    vasanth-ct

  • Drop Off Library and Content Organizer Rules allow bypassing of destination permissions

    I had a test scenario where
    User Betty didn’t have permissions to a destination library (only I had permissions to it)
    Via the Content Organizer rule and the Drop Off library, Betty could send a document to a library where she didn’t have access.
    Anyone addressing this issue and how?  We just don't want people to be able to send things to a destination where they don't have access, but looks like the Content Organizer Rules impersonate some part of the move.
    What's odd is you can see the "CreatedBy" as Betty, but she can't go to the library and even see the moved document...permission is denied.

    Hi Bubberz1,
    This is the known and documented behavior of the content organizer. To prevent someone from using the content organizer in this way, you'd need to prevent them from having access to add documents in the drop off library in the first place, or else
    use some other process, such as workflows, to move the documents using the creator's permissions.

  • Managed Metadata Service and Content Type Hubs - Service Connection necessary?

    I created a site collection and activated the content type hub feature at the site collection level. We have an existing managed metadata service but I am unable to edit its settings, so I created a new MMS in a new database, however; there is no "service
    connection" row below the MMS row for the new MMS Application, but there is one for the old MMS Application. Will this still work with my content type hub? If not, how can I get the service connection setting/row? I have to do this via PowerShell since
    the menus in the ribbon are not usable due to our JavaScript settings...

    Are you using Custom claim provider??
    If you are then try this:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/120ab535-63d2-4205-a51f-1987e9c0cf79/sharepoint-fba-the-content-type-texthtml-charsetutf8-of-the-response-message-does-not-match-the
    http://www.chapmanconsulting.ca/post/2010/04/23/The-Case-of-the-Failing-SharePoint-2010-FBA-Configuration.aspx
    #RoHsTr

  • How to set RelationshipDeleteBehavior on a list using a site column and content type programatically CSOM c#

    On Prem development machine, I'm writng a deployment routine in c# using the client object model.  I've created some site columns of type Lookup, I've created a content type and added those lookup columns to it and I've created a list using the
    content type.  I want to set the RelationshipDeleteBehavior property on some of the lookup columns in the list.  I'm also using the 16 assemblies.
    List list = cc.Web.GetListByTitle("MyList");
    cc.Load(list);
    cc.ExecuteQuery();
    Field f = list.Fields.GetByInternalNameOrTitle("MyLookupField");
    cc.Load(f);
    cc.ExecuteQuery();
    (f
    as
    FieldLookup).RelationshipDeleteBehavior =
    RelationshipDeleteBehaviorType.Restrict;
    f is returning as a Field but (f
    as
    FieldLookup) is returning null here.  Any insight on this?
    Thank you.
    Dan Budimir

    Hi,
    We can use SP.ClientContext.castTo method to convert the field to lookup field . The following code snippet for your reference:
    ClientContext context = new ClientContext("http://siteurl");
    NetworkCredential credentials = new NetworkCredential("username", "password", "domain");
    context.Credentials = credentials;
    Web web = context.Web;
    List list = web.Lists.GetByTitle("MyList");
    Field field = list.Fields.GetByInternalNameOrTitle("MyLookupField");
    FieldLookup lookupField = context.CastTo<FieldLookup>(field);
    lookupField.RelationshipDeleteBehavior = RelationshipDeleteBehaviorType.Restrict;
    lookupField.Indexed = true;
    lookupField.Update();
    context.ExecuteQuery();
    Thanks,
    Dennis Guo
    TechNet Community 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]
    Dennis Guo
    TechNet Community Support

  • Mapviewer SVG and Content-Type http header

    Hello,
    We have a Mapviewer installation that seems to be serving up the wrong Content-Type header for the SVG charts. The map is being created correctly and we can get GIF's and such.
    The wrong Content-Type causes the Adobe SVG viewer to never render the SVG map successfully. When I save the SVG file to the desktop it opens perfectly or if I statically link it in to the web page from the sever it also opens perfectly. Is there some configuration that is missing somewhere on the mapviewer or the application server to correctly set the Content-Type ?
    Notice the content type of the failing map compared to a working SVG chart we have.
    HTTP/1.x 200 OK
    Content-Length: 41979
    Cache-Control: private
    Content-Type: application/octet-streamConnection: Keep-Alive
    Keep-Alive: timeout=5, max=999
    Server: Oracle-Application-Server-10g/10.1.2.0.0 Oracle-HTTP-Server OracleAS-Web-Cache-10g/10.1.2.0.0 (N;ecid=92576875655,0)
    Last-Modified: Wed, 16 Aug 2006 20:31:58 GMT
    Date: Wed, 16 Aug 2006 20:32:01 GMT
    Accept-Ranges: bytes
    instead of a working SVG graphic
    HTTP/1.x 200 OK
    Date: Wed, 16 Aug 2006 20:35:32 GMT
    Server: Oracle9iAS/9.0.2 Oracle HTTP Server Oracle9iAS-Web-Cache/9.0.3
    Content-Length: 3831
    Content-Type: image/svg+xml; charset=utf-8Connection: Keep-Alive
    Keep-Alive: timeout=5, max=999
    This seems to be the last sticking point in successfully rolling out this mapviewer implementation. Any help would be greatly appreciated.
    Thanks, in advance.
    Thanks,
    Carl

    Hello,
    Thanks for the reply I've tried both SVG_URL and SVGZ_URL and used a http header sniffer to watch what's getting served up and the urls associated with MapViewer SVG are definitely getting served up with that wrong Content-Type.
    Our front end is an Oracle APEX environment were we use APEX's SVG charting on the same page and they are getting served up with the correct Content-Type and display correctly, which is nice cause I can watch the header difference's side by side, and we know the mapping itself is working right because we can get image files back
    Is there a sever config file or something like the httpd.conf for apache that needs to be set?
    Thanks for any help or insight
    Carl

  • Exception in encoding and content type

    Hello everyone,
    I am using JavaMail API 1.1.3 to download mails from POP3 servers. The application seems to be working fine except when I am seeing the following entries in the message header:
    1) Content-Transfer-Encoding: 8bits
    Exception -- Unknown encoding: 8bits
    2) Content-Type: text/plain;
         charset="utf-7"
    Unsupported encoding exception -- utf-7 [could not load class sun.io.ByteToCharutf-7]
    3) Content-Type: text/plain;
         charset="koi8-r"
    Did anyone encounter this before and/or have a resolution? Appreciate if you can share if there is a fix.
    Thanks in advance.

    By default, getContent() will return decoded text. But,some mail server will put 8bits instead of 8bit. Javamail will throw exception when encoding is "8bits". In that case, you will have to decode the message by yourself, force using "8bit".
    Part 2 & 3 of the problem - it is not able to find the character set support.

  • Help on Approval Workflow and content types

    Hi
    So here is my question hope you guys can help!
    So i was setting up a workflow for a leave request form. Everything was fine and I had the Approve/Reject buttons at the bottom of the task EditForm. Now I copied the content types to a new one and changed the Optional settings (lets says title hidden %
    completed hidden etc) and then I changed the Task content type too so as to allow for that new content type to take place. Then i relaunced the workflow everything worked nicely the form look the way I wanted it but then on the EditForm I didnt have the ebuttons
    any more so I found it odd so I reset the content type to the original checked that everything was back in place (the hidden back to optional etc) and even on the original Workflow Task (Sharepoint2013) content type the buttons disapear now I have to manually
    add to the completed column and change the drop down menu of the Task Outcome to approved or rejected to make the workflow spit out the results.
    I was wondering what happened I do not understand it. I even deleted all the Task List and Lists associated witht the workflow re wrote the workflow and nothing... So i m a bit out of my depth.'
    When I click on the Cutomized List Default Edit Form... I do get the form with the button but its not the same one I get with the Email Link or the Link and the actual List
    Any pointers?
    I appreciate it!

    Hi  ,
    According to your description, my understanding is that the outcome buttons disappear after you change the Optional type column in Workflow Task(SharePoint 2013)  content type.
    For your issue , please make sure the Task Status and Task Outcome type columns are existing in the content type in order for the custom outcome buttons to appear.
    For more information, you can refer to the blog:
    http://blogs.msdn.com/b/sharepointdesigner/archive/2012/09/14/how-to-manipulate-the-task-form-with-sharepoint-designer-for-new-task-actions.aspx
    As your original demand is setting up a workflow for a leave request form, here is a great blog you can have a look:
    http://jamilhaddadin.com/2011/12/03/implementing-workflow-using-infopath-2010-and-sharepoint-designer-2010/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • HTTPS and content type images

    Why is image considered a unsecure content type over HTTPS?
    Thanks

    That's meaningless. Everything is secure over HTTPS as long as it's implemented properly at both ends.
    Possibly you are referring to mixed HTML pages where the text is transmitted via HTTPS and the images via HTTP.

  • Lost my itune library and content on my window based laptop

    I have lost my iTunes library (all songs, playlist, artist etc.) and do not have backup.  I have approx. 80% of my library on my iphone5 and ipod nano.  My laptop is window based operating system (window 7 professional).  My iphone was just updated to ios8.1.  Anyway to import my 18.2 GB of music back to my laptop?  Thanks
    Kaivon

    Thanks for your help. You were a big help and saved me hundred of hours in re-creating my itunes library of thousands of songs by downloading them again. I managed to get my purchases back using the instructions you provided and used the listing of software providers to download iRip and recover the rest of my music and playlists from both my iphone and ipod (I had different playlist on each).  I basically recovered 99% of what I had lost so that was a huge help.  Once you download iRip you really do use only one click to restore your iTunes library and playlists - super easy.  Thanks again.

  • Image Carousel and Content Type

    I have some URLs for images and PDFs that are being put the SAP Carousel. I'm having the following issue. The URLs I'm using are links to documents in FileNet....which don't end with the file extension...they end with a GUID of the document like so:
    http://www.someplace.com/WorkplaceXT/getContent?mode=download&objectStoreName=test&objectType=document&id={97F6083D-D679-41AB-8758-BD2AEEF14E69}
    The only place I've seen where I can tell if the file is an image or a PDF is in the Response Headers for that image URL in the "Content-Disposition" header.
    Let's say I have 3 images/PDFs...
    <img src="http://www.someplace.com/WorkplaceXT/getContent?mode=download&objectStoreName=test&objectType=document&id={97F6083D-D679-41AB-8758-BD2AEEF14E11}"/>
    <img src="http://www.someplace.com/WorkplaceXT/getContent?mode=download&objectStoreName=test&objectType=document&id={97F6083D-D679-41AB-8758-BD2AEEF14E69}"/>
    <img src="http://www.someplace.com/WorkplaceXT/getContent?mode=download&objectStoreName=test&objectType=document&id={97F6083D-D679-41AB-8758-BD2AEEF14E55}"/>
    What is the best way for me to tell what type of content is actually represented? Can I access the "Content-Disposition" header easily when I load each of the images/PDFs from the URL?

    hi
    try something like this.
    declare
          f varchar2(100);
    begin
         f := webutil_file.file_open_dialog();
         if f is not null then
              :block.item := f;
              end if;
         end;or try the following code.
    declare
    l_file_name varchar2(383);
    begin
    l_file_name := webutil_file.file_open_dialog( );
    if
      l_file_name is not null
    then
      if
        :block.rowid is not null
      then
        create_record;
      end if;
      client_image.read_image_file ( l_file_name, substr ( l_file_name, instr ( l_file_name , -1 ) ), 'block.item' );
    end if;
    end;sarah
    Edited by: QGIRCO on Jan 20, 2010 8:51 AM

Maybe you are looking for

  • How do I put the songs on my Itunes in a backup file/folder?

    Well, i have a ipod 30g video. I just recently cleaned out my computer a little bit and when I try to open my computer it reads: "quicktime failed to initialize (error -2093)." "quicktime is required to run iTunes. Please reinstall iTunes". Now I got

  • Connecting zen touch to an ap

    I am trying to connect my zen touch to an apple computer. It is not registering it, and i can't install the cd. Any Help?

  • Xorg 7.0 with USB mouse wheel

    If the protocol "Auto" (in xorg.conf) doesn't work, try "ExplorerPS/2". Found that in my old X log

  • Page Reload after Submit

    Good Morning, I want my page to reload after a submit. The code I am using is not working correctly. I have a region with a static ID:OPLAN I created a branch with url: f?p=&APP_ID.:12.:&SESSION_ID.::&DEBUG.#OPLAN It doesn't go back to the OPLAN sect

  • Missing  master data for Account number Delta

    Hi, I am working on production system,Some records are missing master data(attributes street,city for Account number  for starting with Account number   9xxxxxx) for Delta load,Field lenguth is 10.these Missing  records are getting loaded with full l