Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

June 11, 2012

Creating a Custom Action by Using a Feature

The following steps create a custom action in Visual Studio 2010.
The procedures in this section assume a development environment where SharePoint 2010 is installed and configured, Microsoft Visual Studio 2010 is installed and the currently logged-in user has administrative rights on the SharePoint environment for deployment purposes.
To Create a Custom Action by Using a Feature
  • In Visual Studio 2010, click New Project, expand the SharePoint node, click 2010, and then click Empty SharePoint Project. Name the project E-mail a Link and then click OK.
  • In the SharePoint Customization Wizard, select the local SharePoint site that can be used for debugging and whether the solution will be deployed as a sandboxed or farm solution as shown in Figure 1.
  • Click Finish.
    Figure 1. Specify the deployment method 

  • In Solution Explorer, right-click the Features node and then click Add Feature as shown in
    Figure 2.
    Figure 2. Add new feature
  • Name the feature E-mail a Link and add a description as shown in Figure 3.
    Figure 3. Name the feature
  • In Solution Explorer, right-click the E-Mail a Link project, select Add, and then select New Item as shown in Figure 4.
    Figure 4. Add a new item to the project
  • In the Add New Item dialog box, select the Empty Element template, type E-Mail a Link as the name, and then click Add as shown in
    Figure 5.
    Figure 5. Add an element to the project
  • Open the Elements.xml file inside E-Mail a Link and then replace the file content with the following code example. If you like to apply this E-mail a Link to all the Lists, Change RegistrationsType From "ContentType" to "List" and RegistrationId from unique number to "101"
    XML
    1. <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
      Description="Email A Link"
      Title="Email A Link"
      Id="{E538E8C7-65DA-454E-AD87-4A603B6CC569}"
      Location="CommandUI.Ribbon"
      RegistrationId="0x0100...(put actual Id here)"
      RegistrationType="ContentType"
      Sequence="1"
      Rights="ViewListItems"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Define the (UI) button to be used for this custom action -->
    <CommandUIDefinitions>

    <CommandUIDefinition Location="Ribbon.ListForm.Display.Actions.Controls._children">
    <Button Id="{B511A716-54FF-4EAE-9CBE-EA02B51B626E}"
    Command="{4E2F5DC0-FE2C-4466-BB2D-3ED0D1917763}"
    Image16by16="/_layouts/1033/images/formatmap16x16.png"
    Image16by16Top="-16" Image16by16Left="-88"
    Sequence="500"
    LabelText="E-mail a Link"
    Description="E-mail a Link"
    TemplateAlias="o2"
    />
    </CommandUIDefinition>
    </CommandUIDefinitions>
    <CommandUIHandlers>
    <!-- Define the action expected on the button click -->
    <CommandUIHandler Command="{4E2F5DC0-FE2C-4466-BB2D-3ED0D1917763}" CommandAction="javascript:mailThisPage();" />
    </CommandUIHandlers>
    </CommandUIExtension>
    </CustomAction>
    <CustomAction Location="ScriptLink" ScriptSrc="/_layouts/xxxx/xxxx.js"/>
    </Elements>
  • Save the file.
  • Add the E-Mail a Link element to the E-mail a Link feature as shown in Figure 6.
    Add the E-Mail a Link element to the E-mail a Link
    feature as shown in Figure 6.
  • Right click the solution name and then click Deploy as shown in Figure 7. Visual Studio 2010 will build and deploy the solution to the farm.
    Figure 7. Build and deploy the solution
  • Navigate to the local site, Enable the feature E-mail a Link.
  • Add custom and name it as Promotion list, and then Click on View Item. Observe the "E-mail a Link" under the Action Group as shown in Figure 8.
    Figure 8. The E-mail a Link button
  • Click the "E-mail a Link" button and notice the default Email application open with the link to this item.
If you have any questions you can reach out our SharePoint Consulting team here.

May 28, 2012

Generate test data using GenerateData.com

Introduction:
There are times when you need test data in order to test how your application scales. GenerateData.com helps you generate test data in many popular formats like html, xml, csv. excel etc. Let's see how we can use it.
How to:

  • Goto generatedata.com
  • Enter column name in column title and select Datatype from drop down.
  • For ID AutoIncrement Datatype is selected and in options (Start at ) 1 is entered because from which value user wants to start his id number.
  • And in increment it is given 1 because user wants to increase its id by 1.
  • Second field is inserted (Functional Group) whose DataType is custom list . The item of custom list is inserted in Enter values Seperated textbox and items should be separated by “|”.
  • If user has more rows then shown than user can add more values by entering exact figure and click on Row(s) textbox.​
  • After entering all data user has to select Result Type, For Result type option is given on top (HTML,Excel,XML,CSV,SQL), Select the desired Result Type. 
  • And finally click on generate button and if user has selected Excel for result type and an excel will generate and then user can import excel to Database.
Conclusion:
It is really easy and straight forward to genreate test data for almost any kind.
If you have any questions you can reach out our SharePoint Consulting team here.

March 28, 2012

jQuery.find not working in IE7 for xml data

As part of troubleshooting a shareoint functionality, we found that jQuery.find not working.

We were using jQuery.ajax to call a sharepoint web service and in success function, finding an element in response xml to render it on div.

We fixed this and there are couple of options to fix this that we found from stackoverflow.

1. add dataType: 'xml​' in jQuery.ajax and that will fix it.

2. in response, check for browser is IE7 and variable that is having data is blank, do it with another method, here is javascript code:


if ($.browser.msie && liHtml == "") {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(response);
liHtml = $("XmlTagNameToFind",xml).text();
}

"liHtml" is the variable which has jQuery.find().text() output.

I hope this will help you as well.

If you have any questions you can reach out our SharePoint Consulting team here.