Thursday, May 23, 2013

Immediate alerts not working on a list/document library

There are various issues with the sharepoint alerts.
Problem 1: Not a single site sends the alerts.
Problem 2: A specific site fails to send the alerts
Problem 3: A specific user fails to receive the alerts

Problem 1:Not a single site sends the alerts.
After registering for alerts on a SharePoint list/document library, you get the welcome email "You have successfully created an alert for 'doc lib' ". But you will never get the actual alert mail for the changes on the document/item you marked for an alert.
Reason:
There is a config/environement change that was not reflected into the config database or config cache.
Fix:

  1. Stop the WSS Sharepoint timer service
    start -> admin tools -> services -> Windows Sharepoint Services timer -> stop.
  2. delete the un used Alternate Access Mappings(CA-> Operations -> Alternate Access mappings), un used IP configurations, orphans in the DB.
  3. Clear the config cache.
    - Go to the local sharepoint config files folder:
    C:\Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config\ConfigDB ID
    - Delete all the XML files and do not delete the "cache.ini" file.
    - Delete all the numbers in the "cache.ini" , type 1 and save it.
  4. Start the WSS Sharepoint timer service
    start -> admin tools -> services -> Windows Sharepoint Services timer -> Start.
  5. Check whether the timer job is successful or not. Also see the Immediate alerts status.
    CA -> Operations -> Timer Job Status
  6. Check whether the 'alerts' is configured in Minutes :
    A -> Operations -> Timer Job definitions.
  7. Some times there will be a problem with the mail provider settings.Check the SMTP Relay settigns to see the IP Address configured properly.
Problem 2:A specific site fails to send the alerts
Reason:

There is a config/environment change in a specific site. In other scenarios, if a site is migrated from different environment or another version. So, you do not get alerts on that specific site.
Fix:
  1. (Do this step if your environement is flexible)
    Create a new web application/new content database and test for the alerts. On success, move this perticular problematic site to the new web application/content database.
  2. Force the "alerts enabled" command on the perticular site.
    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN> stsadm.exe -o setproperty -pn alerts-enabled -pv "true" -url http://sitename/.
    You will be fine.
Other commands:
Though you can do all these below commands through CA UI, STSADM is preferred.
  1. To verify whether a site has the alerts enabled:
    Stsadm.exe-o getproperty -url http://sitename/ -pn alerts-enabled
    This will return Yes or No.
  2. To disable alerts on a site:
    stsadm.exe -o setproperty -pn alerts-enabled -pv "false" -url http://sitename/
  3. Verify the job-immediate-alerts. Should be every 5 minutes.
    stsadm.exe -o getproperty -url http://sitename/ -pn job-immediate-alerts
  4. If the above command returns any thing other than "Every 5 minutes between 0 and 59", set the time
    stsadm.exe -o setproperty -pn job-immediate-alerts -pv "every 5 minutes between 0 and 59" -url http://sitename/
Problem 3: A specific user fails to receive the alerts
Reason:
There must a problem with the registered email id. Or user might not have at least "read" access on the document library.
Fix:
  1. Check for the user access on the doc library. If not, add the user with at least "read" access.
    It may happen that the user gets the initial mail. Coz, initial mail doesnt look for the permissions before sending the mail.
  2. While configuring, use the "email id" instead of the usual "Domain\Name". If succeeded, then there must be a problem with the email id registered.
  3. To confirm the email not in sync,
    SQL -> Associated Content Database -> Tables -> ImmedSubscriptions -> email field.

Thursday, April 11, 2013

How to Copy an Assembly From the GAC to the File System

Sometimes you need a local copy of an assembly from the GAC and here is a quick tip on how to do it. The GAC can be found in the c:\windows\assembly directory, but if you try to browse it, the following custom shell extension appears:

image

This view does not provide the ability to copy assemblies, but it does provide some very useful information such as the strong name details. Here are some options to get around that feature to copy an assembly from the GAC.

Option 1: Disable the Shell Extension in the Registry


One possibility, but not the best one, is to disable the shell extension. I don't like this approach because it involves editing the registry and I like the information provided by the shell extension. Here's how to disable the extension if you want to. Open the registry editor and add/set the HKLM\Software\Microsoft\Fusion\DisableCacheViewer DWORD value:

image

Set the value to 1:

image

Once you make that change, you can browse the directory:

image



Option 2: Go Command-O


Another option is to copy assemblies from the GAC from the command line. This approach works well if you prefer working from the command line, but if you like to right-click with a mouse, this might not be the choice for you.

I highly recommend PowerShell, but you can use Windows Command Prompt. Find your way to the c:\windows\assembly directory and copy the file you need:

image

Option 3: Use the SUBST Command


The SUBST command allows you to create a shortcut to a path on your file system and assigns that shortcut a drive letter. I really like this approach because you have the option of using Windows Explorer without having to disable the shell.

Suppose you want to create a G Drive (G for GAC), use the following command: SUBST G: C:\WINDOWS\ASSEMBLY

image

Then in Windows Explorer you are free to double-click and right-click to your heart's content and still use the shell extension.

image

Saturday, August 4, 2012

Printing just the web part and not the entire SharePoint page

I observed many times infopath webbased form not print full form contents. it's only print Firstpage of the form remaining pages print blank e.g if my webbased form has 4 pages if i print this form browser based file\print\ button, it print only first page remaining 2,3,4, pages print blank but here it print header and footer, but i does not print full webpart contents.

so i decided to work on this topic
Insert a Content Editor Web Part and edit the source code. Add the following to it:

<input type="button" OnClick="javascript:void(PrintWebPart())" value="Print Web Part">
<script language="JavaScript">
//Controls which Web Part or zone to print
var WebPartElementID = "<WebPartElementID>";

//Function to print Web Part
function PrintWebPart()
{
var bolWebPartFound = false;
if (document.getElementById != null)
{
//Create html to print in new window
var PrintingHTML = '<HTML>\n<HEAD>\n';
//Take data from Head Tag
if (document.getElementsByTagName != null)
{
var HeadData= document.getElementsByTagName("HEAD");
if (HeadData.length > 0)
PrintingHTML += HeadData[0].innerHTML;
}
PrintingHTML += '\n</HEAD>\n<BODY>\n';
var WebPartData = document.getElementById(WebPartElementID);
if (WebPartData != null)
{
PrintingHTML += WebPartData.innerHTML;
bolWebPartFound = true;
}
else
{
bolWebPartFound = false;
alert ('Cannot Find Web Part');
}
}
PrintingHTML += '\n</BODY>\n</HTML>';
//Open new window to print
if (bolWebPartFound)
{
var PrintingWindow = window.open("","PrintWebPart", "toolbar,width=800,height=600,scrollbars,resizable,menubar");
PrintingWindow.document.open();
PrintingWindow.document.write(PrintingHTML);
// Open Print Window
PrintingWindow.print();
}
}
< /script>

Once you have done the above, you need to find the web part id of the web part you want to print when this button is clicked.
To do that, you view the source of the page and look for the web part title corresponding to the web part. It looks something like this:
<div WebPartID="0e77b913-99e6-402c-8558-cdd5a2100eb2" HasPers="false" id="WebPartctl00_m_g_0e77b913_99e6_402c_8558_cdd5a2100eb2" width="100%" class="ms-WPBody" allowDelete="false" style="" >
The id that you're interested in to replace <WebPartElementID> in the javascript above is highlighted.
Once it's all there, click on the button and a window will pop open that contains only the contents of the web part. Feel free to print.

Friday, July 13, 2012

InfoPath 2010: Pre-populate the People Picker

This solution can be done with any version of SharePoint 2010 or SharePoint Online with Office 365.
Here’s a little bit of background on how the people picker is structured:image
It is structured as a repeating table, and the “group” can be renamed. No other fields can be renamed
DisplayName = Nizamuddin
This is the first name and last name of the user, which is going to be equivalent to the value of the PreferredName field in the user profile service.
AccountId = contoso\Nizamuddin
This is domain\username
AccountType = User
This is User or Group.
image
Here are the steps to prepopulate the people picker:
  1. On the Data tab, click Data Connections. Click Add..
  2. Choose Receive data and click Next. Choose SOAP web service, and click Next.
  3. Type the URL of your site, and after the site, type /_vti_bin/userprofileservice.asmx
    Click Next.
  4. Choose GetUserProfileByName. Click Next. Click Next. Click Next. Click Finish. image
  5. All we’ve done so far is create a connection to the user profile service web service, so that we can get some additional information about the logged in user. Since we only want the people picker to get pre-populated when it’s a new form, we’re going to create a form load rule that does this.
    If you haven’t already placed a people picker control on your InfoPath 2010 form, go ahead and do that.
  6. On the Data tab, click Form Load.
  7. In the form load rule pane on the right, click New and choose Action.
  8. We only want this to happen if there’s no name in the people picker yet, so we’ll create a condition first. Under the word “Condition”, click the blue word None – …
  9. Creating the condition: In the first drop-down box (myFields), click Select a Field or Group. Navigate down to your people picker control group and expand it. Select the AccountId and click OK.
    CropperCapture[38]
  10. On the condition’s second drop-down, choose Is Blank. Click OK.
    CropperCapture[40]
  11. Back in the form load rule pane, click Add and choose Set a Field’s Value.
  12. For the Field box, select the DisplayName field inside your people picker form (that DisplayName field you see in the screenshot at step 9). Click OK.
  13. Click the fx (function) button next to the Value box. Click Insert Field or Group… In the Fields drop-down box, choose GetUserProfileByName.
    CropperCapture[41]
  14. Drill all the way in the DataFields until you get to Value. CropperCapture[42]
  15. Click the Filter Data button. Click the Add button.
  16. In the first drop-down box that says Value, choose Select a field or group. Select the Name field. Click OK.
  17. Leave the middle drop-down to say Is equal to. In the third drop-down box, choose Type text. Type the word PreferredName It will automatically put the quotes around it for you, you don’t need to type those. (this is case sensitive, so you have to type it exactly right) Click OK.
    CropperCapture[43]
  18. On the Filter Data screen, click OK. On the select a field or group screen, click OK. On the insert formula screen, click OK.
  19. This is what your Rule Detail screen will look like. Click OK.
    CropperCapture[44]
  20. Back over in the form load rule pane on the right, click the Add button again, and choose Set a field’s value.
  21. For the Field, drill down to your form’s people picker, and select the AccountId field, as seen in step 9. Click OK.
  22. Repeat steps 13-16.
  23. Leave the middle drop-down to say Is equal to. In the third drop-down box, choose Type text. Type the word AccountName Click OK.
  24. This is what your Rule Detail screen will look like. Click OK.
    CropperCapture[45]
  25. In the Rule pane on the right, click the Add button yet again. Choose set a field’s value.
  26. For the Field, pick the AccountType field within your people picker. You can see what this field looks like back in step 9. Click OK.
  27. In the Value box, just type the word User
  28. This is what your Rule Details screen will look like. Click OK.
    CropperCapture[46]
  29. Done. Publish your form and try it out. When you fill out a new form, your own name will be populated in the people picker.

Thursday, April 26, 2012

enable Audit functionality in SharePoint 2010

How to enable Audit functionality in SharePoint 2010



“Microsoft SharePoint Server 2010 includes four information management policy features to help you manage your content: expiration, auditing, document labels, and document bar codes. - msdn.microsoft.com”.
In this post I will focus on the audit capabilities in SharePoint 2010, more specifically how to enable the audit functionality.
When the audit functionally is enabled it will automatically log events and activities that is done on your content. The content could be documents, records and other items, such as task list and calendars.

Why

Why would you enable auditing in SharePoint? There could be different reasons, and they often depend on which vertical (e.g. Public/Government) you are located in.
  • Meet Regulatory and Legal requirements.
  • Track how documents (and items) are used.
  • Keep track of document history if documents are sent to the Content Organizer. When using the Content Organizer, the document’s version history is deleted. The audit log will be your source to the document history.

How

An Administrator has access to configure auditing, but a developer can also create custom code that read and write to the audit log. More details here: http://msdn.microsoft.com/en-us/library/ms441917.aspx.
What’s available for the administrator? The audit functionality can be enabled on different levels in SharePoint’s containment hierarchy. Specifically, you can enable auditing on these levels: site collection, library/list, folder, and content type.
Site Collection
  • Go to Site Actions –> Site Settings –> Site Collection Administration –> Site Collection audit settings.
  • Under the Document and Items section you can enable the events you would like to audit:
image
On the same page you also have the option to enable audit logging for Lists, Libraries and Sites:
image
Library/list
  • Go to [yourlibrary] –> Library Tools/Library –> Library Settings –> Permissions and Management –> Information management policy settings.
  • Under the Content Types Policies section you can define a new policy or choose an existing policy (created in the site collection).
image
  • More about how to create site collection policies later… In this example a choose “Define a policy…”
  • Scroll down to Auditing where you will be able to choose the events you want to add to the audit log:
image
Hey, wait a minute! This is not enabling auditing of all documents in this library.
True. It is more about being able to apply different events to audit, to different libraries, even when those libraries are using the same content types. Which leads us to how to apply auditing on the content type.
Content Type
  • Go to Site Actions –> Site Settings –> Galleries –> Site Content Type.
  • Scroll down to Document Content Types and click on Document.
  • Under Settings click on Information management policy settings:
imageClick on Enable Auditing and then select the events you would like to be written to the audit log.
Hmmm…. what happens if I have applied auditing on a content type, and now are trying to apply different rules at the library level?
Following the example above, I have enabled the “Edit items” events on the Content Type level. Going back to my library and into my library settings I find that I can’t apply specific policy settings because the library inherits the settings from the Content Type:
image
So, if you need to differentiate audit settings between libraries you cannot configure audit settings on the Content Type level.
Folder
A folder (in a library) is just another content type. See details above on how to configure auditing on content types.
Site Collection policies
You can predefine information management policies, and make them available for use within your site collection
  • Go to Site Actions –> Site Settings –> Site Collection Administration –> Site Collection policies.
  • Click Create.
  • A new page will let you predefine policies that also include more than the auditing. E.g you can create a policy for your Contracts that include both audit and retention settings. Having the policy predefined may make it easier for administrators to apply the correct policy to their content types.
image

Other things to consider…

Audit log trimming
By enabling auditing in a SharePoint environment with a large number of events, you will potentially end up with a large audit log which can affect the over all performance. It is recommended to enable audit log trimming for site collections with extensive auditing.
  • Go to Site Actions –> Site Settings –> Site Collection Administration –> Site Collection audit settings.
image
As you can see, the number of days of audit log data to retain is an optional field. If you don’t set this value the trimming will follow settings on the Farm level. This is done by the Farm Administrator using Central Admin.
Limit the size of the audit log
Only audit the events required to meet your needs. Which one of these events do you really need to log?
image

Audit log reports

Ok, I have enabled auditing.. how do I access my audit log?
I recommend you to check out this page for details: http://office.microsoft.com/en-us/sharepoint-server-help/view-audit-log-reports-HA102039795.aspx

Resources

Configure audit settings for site collection http://office.microsoft.com/en-us/sharepoint-server-help/configure-audit-settings-for-a-site-collection-HA010099726.aspx
Version history erased when using Content Organizer http://technet.microsoft.com/en-us/library/ff453933.aspx#Auditing
SPAudit Class http://msdn.microsoft.com/en-us/library/ms441917.aspx
View audit log reports http://office.microsoft.com/en-us/sharepoint-server-help/view-audit-log-reports-HA102039795.aspx

Tuesday, March 27, 2012

Control Formatting of SharePoint Announcements

Here are the steps:

  1. Create an "Announcements" list, if there isn't already one on your site.
  2. Create a list called "Create Announcements", using the list template "custom list".
  3. Create the following columns in the Create Announcements list:
    Green Header - Single line of text
    Brown Header - Single line of text
    Body - Multiple lines of text - Enhanced rich text
    Photo URL - Hyperlink
    Expiration - Date/Time
    Then, I renamed "Title" to "Black Title"
  4. In the Announcements list, a template must be created. Create a new announcement. Make up a title, and then put the cursor in the body of the announcement. Since I want to show the speaker's photo to the left of the session description, I create a table. On the Insert tab, insert a table that's got one row and two columns.
  5. In the left cell of the table, type "Picture", as a placeholder. In the right cell, type the following:

  6. Now it's time to apply the colors. Select the text, and apply your desired colors to each line, as so:

  7. Click Save.
  8. Open that same announcement back up, click to edit it, and put the cursor in the Body field. Open the HTML source code, like this:

  9. Copy the HTML code to the clipboard. Open SharePoint Designer.
  10. Create a new workflow based on the Create Announcements list. Name it "New Announcement".
  11. Add an action to set a workflow variable. (In SharePoint 2007, the action is called Store Dynamic String) Call the variable BodyTextVar, and it is a string variable.
  12. Click the blue word Value. Click the little ellipsis next to it (the button with 3 dots). Paste the contents of the clipboard, which is the HTML source code. Mine looks like this
    <div class="ExternalClassF2152D91E5604C86AA56CB2DF7047264"><table width="100%" class="ms-rteTable-default" border="0" cellspacing="0"><tbody><tr><td>Picture</td><td><p style="color: #000; font-size: 18pt"><strong>Black Title</strong></p><p style="color: green; font-size: 12pt">Green Header</p><p style="color: #8f6c2e; font-size: 10pt"><strong>Brown Header</strong></p><p>Body</p></td></tr></tbody></table></div>
  13. In the spot of the code where you see the word "Picture", that needs to be changed to HTML code for a picture. The Photo URL field will be used. Basically, each placeholder in the code will be replaced with the name of the actual field from the list, like this:

  14. Note that when you insert the Body field, be sure and change Return field as: Plain Text.

  15. When you insert the Photo URL field, be sure to select Return field as: URL
  16. I used the <Add or Change Lookup> button in the code, to insert where the fields need to go. For example, I replaced Green Header with the actual field called Green Header. Click OK.
  17. In the workflow, add the action Create List Item.
  18. Click the blue words This List, and pick Announcements.
  19. Set the Title field to the current list's Black Title, and click the Add button. Add the body field, like this, and click OK twice.

  20. One more field. Click the Add button. Choose "Expires" and match it to the current list's "Expiration". The Create new list item action will then look like this. Click OK.
  21. Publish the workflow. Note that since we didn't change the workflow initiation (Start) settings, it is only set up to be triggered manually, which is fine for testing.
  22. Before you create an item in the Create Announcements list, be sure to get the URL of a photo that's in a library in SharePoint, to paste into the Photo URL field. Create a new item in the Create Announcements list, and fill in all the fields. Run the workflow.
  23. You'll notice that your new announcement gets created. Lovely! Any tweaking that needs to be done regarding formatting and alignment needs to be done in the HTML code that's in the first action "set variable" in the workflow.
  24. Another enhancement: You may want users to be able to create items in Create Announcements but not create or edit items in the actual announcements list. This can be done. In the workflow, insert an Impersonation Step, and put those 2 steps inside of it. That way, you can take away the users permissions to contribute to the announcements list, and the workflow will still be able to create items in it, because it runs with the credentials of you, the person who published the workflow.
  25. The web part view: In the Announcements list, create a new view. Make it a Standard view, and call it Web Part. Only check the box next to the Body column. Set the filter so that Expires is greater than or equal to [Today]. Uncheck the box next to Tabular View.
  26. On the home page of your site. Go to the web part toolpane of the Announcements web part. Change the view to this new Web Part view that you just created. Click OK. What is this for? Now, your announcements will be fully displayed on the home page without being cut off, and since we inserted the title field into the body of the announcement, only the body field needs to be shown.

display a “More” link on your announcements web part

Here is how to display a “More” link on your announcements web part, so that users will have an obvious link to click on, to read more of each announcement.

  1. Create a new column in your announcements list called “More”, with a field type of “Hyperlink or Picture”
  2. In SharePoint Designer, create a new workflow - Open SharePoint Designer, and click <File> and <Open Site>
  3. Put in the URL of the site where you’d like to create the workflow, and open it.
  4. Click <File>, then <New>, then <Workflow>
  5. Pick your Announcements list from the drop-down list. Only check the box “Automatically start this workflow when a new item is created”.



  6. Note: If there is already a workflow running when a new item is created in this list, such as the one created in the first section of this article, I recommend adding this as a new step in the same “Create Announcement” workflow, as opposed to having two different workflows running when each item is created in the list.
  7. This workflow will have no condition.
    Action: Build Dynamic String
    Click on dynamic string, which will take you to the String Builder dialogue box. Type a backslash, then click the <Add Lookup> button.
    More Link

    Pick the Path field, and click OK, then type the rest of the string as so:

    More Link

    (The reason for the comma and “Click Here” is so that users aren’t presented with a big long URL to click, but some nice, short text)

    Give the variable a name such as AnnouncementURL
  8. Next Action: Set Field in Current Item -
    Set the More field to … click the function button.
    More Link

    In the Source drop-down box, choose “Workflow Data”, and for the field, choose the variable that you called “AnnouncementURL” in step 6 above.
    More Link
  9. Now, in the announcements web part on your site, edit the web part properties, edit the current view, and add the new “More” field to the view.
  10. You can even hide this new field, so it doesn’t display on your announcement forms. In the announcements list settings, go to Advanced settings. Change the setting “Allow management of content types” to Yes.
  11. Now, there’s a new section in your list’s settings called Content Types that contains one content type called “Announcement”.
  12. Click on the Announcement content type, click on the More field, and change it to Hidden. This will still allow the column to be added to any view, but the field will be hidden when opening or editing the announcement itself.