Showing posts with label metadata. Show all posts
Showing posts with label metadata. Show all posts

Monday, July 29, 2013

InfoPath dropdown with different Value and Display Name

InfoPath dropdown comes with an ability to have different values being sent to the list/database and a different value to be viewed by users. For eg., you bind a dropdown which fetches users from a SharePoint security group and you want to display the “Display Name” attribute of the user within the dropdown values at the same time you want to map this field to a People picker field within the list and for that purpose you want to send the “Login Name” attribute to the people picker field. In such a scenario, follow the screenshots to create a similar functionality.

Click on the Dropdown properties

Select the datasource from the Data source dropdown or you can create one here as well. Then click on the Select XPath button (highlighted in the image).
In the Entries field, select the parent node and click OK.
This will enable you to select two different values for the Value and the Display Name field.
Now from the returning values, select the ones you want for each field and save your form.
To view your changes, you may want to publish the form and verify the changes.

Monday, April 1, 2013

Creating Event Recievers within Visual Studio 2010

Event receivers can be broadly seen as of two types:

Asynchronous (triggered before finishing of previous event)
          ItemAdding, ItemUpdating
Synchronous (triggered after finishing the previous event)
          ItemAdded, ItemUpdated

Follow Steps to create an event receiver with Visual Studio 2010 and SharePoint 2010 :
  • Open up Visual Studio 2010 with administrator privileges
  • Click File > New > Project
  • Under Installed templates, click SharePoint and then select Event Receiver (C# in my case). Enter the name, storage location and Solution name in the text box provided and click on OK.
    • It will then ask you to specify the site and trust level or scope of your solution. If you want to deploy it across your farm so that all web applications can make use of it, you should select Deploy as Farm Solution. However, with event receivers, it is not usual so we will select Deploy as Sandboxed solution, which means it will only be accessible to the sites where we activate this feature.
    • Now it will ask you to select the type of Event Receiver you would like to create. In our case it would be List Item Events. Then select what item should be the event source, here we will select Document Library as we want to create an item in document library and want our event receiver logic to run after that. You may want to select Picture library or a list here or as per your business scenario.

    • Now, check the events you would want to code for within your receiver. For the sake of example, I will check An Item was Added which means it will automatically create a method stub for me with ItemAdded method. Now click on Finish.


    Our development IDE is ready to use now and you can see the method stub for ItemAdded being created already.

    Copy and Paste the code below to your solution.
    using (SPWeb web = properties.OpenWeb())
    {
        //Name is a metadata column within my document library
        //Checking if the Name field is equal to Test
        if (properties.ListItem["Name"] == "Test") 
        {//If it is
            // Populating the Title field with some value
            properties.ListItem["Title"] = "Event handler works"; 
            // Updating the ListItem to incorporate the change. 
            // Necessary step, without this  the changes are not pushed to ListItem
            properties.ListItem.Update(); 
        }
    
    }
    
    
    Some more useful methods which can be used are
    //Name of the Document Library
    string DocLibraryName = properties.ListTitle.ToString();
    
    //Getting the Item ID
    int ItemID = properties.ListItem.ID;
    
    //Collection of Role Assignments - required for controlling permission to the Item
    SPRoleAssignmentCollection roleAssignment = properties.ListItem.RoleAssignments;
    

    Build the solution and deploy it. Go to your SharePoint site and activate it(if not already activated) and create any document library and create an item with Name as Test and see your event receiver in action.

    This event receiver will fire on all the document libraries within your site where you have activated the feature, if this is not the intended behaviour, use
    if(properties.ListTitle.ToString() == "DocumentLibraryName")
    
    And write all your logic within your IF block.

    For any queries please feel free to email me. If this post helped you, please share it and benefit more and more fellow SharePoint developers

    Saturday, July 21, 2012

    SharePoint 2010 Content Management

    Enterprise Content Management(ECM) combines the traditional content management, social capabilities, and powerful search, it is as natural to manage as it is to use. With its simple, “behind-the-scenes” administration, we can configure the content management to our use.

    I would like to explain some of the aspects of Content Management in this article.

    As we come across managing the content within an organization, we deal with metadata which is the data about data. MOSS 2007 has site columns as metadata which were very useful in organizing and searching data. SP2010 comes up with more such ease of managing your data and meta with concepts with content organiser, in place record management, document id and so on.

    Let take Document ID feature first, so in SP2010 whenever any document is uploaded, it is assigned a unique Document ID which remains with the document throughout its life cycle irrespective of which library/site it is in. This makes documents easily searchable and more manageable. With the document ID,we can search it and locate its current position. Its always good to have one unique field associated with our content and this time SharePoint gives it to you by default.

    SP2010 makes the use of managed metadata which was there in MOSS2007 but in a very efficient way. For that we first need to understand the concept of Term Store. A term store is a collection of Term Sets which is again a collection of Terms. Now terms are the tags which we define in central admin which can be used across our site collection level or web application level. We need to create a set of terms and name them according to our line of business (LOB). The set of these term sets are called term store. Now lets go to our document library settings and try adding a new field as managed metadata, it will bring you with the option to select yours tags, which are same as what we just defined in central admin now as term sets. We can select single or multiple tags as per the requirement. This makes our content easily manageable and fast searchable.

    So we see that managed metadata connects our term sets and the content.

    Another new feature In Place Record Management is another important feature by which we can declare a content as Record and it will behave in a specific way we assign. For that we have to initially configure how we want the records to behave and then declare the content (as required) as Record, using an inbuilt ribbon button. This separates that particular content from others and is very useful when we are dealing with archival of documents.

    Content Organizer (Metadata driven) can create deep, hierarchical folder structures and manage retention at each folder in the hierarchy(or inherit from parent folder) and route incoming documents to the libraries. So we see that it can act as a post office where all the documents arrive and then routed to their specific houses from there. We can configure our emails to arrive here and based on rules (metadata), we can route our content.