SharePoint: Custom alert template for a specific list view - sharepoint

Is it possible to use a different alert template for a specific list view?
An example... My list sends alerts using the default OOTB "SPAlertTemplate.GenericList" template whenever new items are added to it. However I want to instead use a custom email template whenever items are added that appear in the High Risk Incidents view.
I know how to create custom alert templates and associate them with a specific list -- just not how to associate them with a specific view of a list.

According to the Alert template documentation you can use CAML in the FilterDefinition property to control what items are shown.
I don't believe you can point it at a view directly, but you could use the same conditions in your view in the FilterDefinition.
So if your view was made up of the condition RiskLevel=1 then you could use something like the following:
<FilterDefinition>
<FriendlyName>CustomFilter1</FriendlyName>
<ShortName>CustomFilter1</ShortName>
<Query>
<Eq>
<FieldRef name="RiskLevel"/>
<Value Type='Text'>1</Value>
</Eq>
</Query>
Some of these links may help:
Alert Template Format -
http://msdn.microsoft.com/en-us/library/bb802961(v=office.12).aspx
Intro on CAML Query -
http://sharepointmagazine.net/articles/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list

Related

Add-PnPDataRowsToProvisioningTemplate with empty -fields parameter not working?

I want to use a modern SPO team site als a template for similar projects with a prefilled task list (very similar projects).
I created a site template with Save-PnPProvisioningTemplate and tried to add the Data rows with Add-PnPDataRowsToProvisioningTemplate and a empty -fields parameter but that does not work. I need exact the same task list as in the template.
Does anybody know if this is a bug?
I already discussed on this particular topic right here: https://learn.microsoft.com/en-us/answers/questions/211447/copy-spo-team-site-with-task-list-contensrow-data.html?childToView=215328#answer-215328 but wanted to check here before I post a bug on github.
Thanks
Chris
According to the documentation of Add-PnPDataRowsToProvisioningTemplate for the parameter fields:
The fields to retrieve. If not specified all fields will be loaded in
the returned list object.
So, if you leave the -fields parameter empty, it will load all fields including default system fields like Created, Created By, Modified... These default fields are generated by SharePoint and could not be added/edit manually. I think that's the reason that would not work.
So you need to specify the fields parameter which can be edited by end users. Like
column duedate, Title, startdate in the command.
Note: you need to use the internal name of the column, for the description column in the task list. The internal name is Body.
You could change field in the template <FieldRef Name="Description" /> to <FieldRef Name="Body" />. Maybe it would work fo you

SharePoint List Of Recently Updated Pages

I am trying to find a way to inform a group of users whenever any of the pages in our SharePoint site are updated.
Originally we were going to use alerts, but we have numerous subsites in our site. This means (to the best of my knowledge) that we will have to set up alerts for every subsite. This is not an option because subsites will be created and removed and we would rather not add an extra step here.
Secondly, we wanted to use a Content Query webpart to simply show all pages that were updated in the last 5 days. This would allow us to show every page for every site, but I can't figure out how to get it to only show items with an update date >= today's date - 5.
If anyone can help me out, I would really appreciate it. Thanks!
I think you're on the right track with the Content Query Web Part. Unfortunately out of the box it forces you to set a specific date rather than a certain number of days.
Your best option is to override the Content Query Web Part or write your own that provides the functionality you require. There may also be other query web parts available that do this for you. If you write your own, the following CAML query should help:
<Where>
<Geq>
<FieldRef Name='Modified' />
<Value Type='DateTime'>
<Today OffsetDays='-5' />
</Value>
</Geq>
</Where>
The What's New Web Part by Jan Tielens is good for this sort of thing, and it has a few configurable parameters, such as maximum age of items, scope (recursive etc) and the ability to filter by content types.
http://smarttools.codeplex.com/Wiki/View.aspx?title=What%27s%20New

SharePoint: Filtering a List that has Folders

I have a SharePoint document library that has a folder structure used for organizing the documents (but also for controlling access, via permissions on the folders).
The documents in the library are updated every month, and we store every month's version of the document in the same folder; there's a "month" column used for filtering that will contain values like Jan 09, Feb 09, etc. It looks like this:
Title Month
----- -----
SubFolder 1
SubFolder 2
[] Interesting Facts Jan 09
[] Interesting Facts Feb 09
[] Interesting Facts Mar 09
[] Fascinating Numbers Jan 09
[] Fascinating Numbers Feb 09
...
Now, because users will generally be most interested in the 'current' month, I'd like them to be able to apply a filter, and select (say) Mar 09. However, if they do this using the built-in filtering, it also filters out the folders, and they can no longer navigate the folder hierarchy. This is no good - I want them to be able to move between folders with the filter intact, so that they don't need to keep switching it off and on again.
I figured I might be able to use a custom view (selecting where type=folder or month=[month]), and to an extent that does work. However, I can only get it to work for a fixed month, whereas I need the user to be able to select the month - perhaps via a drop-down control on the page (and I don't want to create 60 views for 5 years' worth of months, nor do I want to have to create a new view every month).
I thought it might be possible to create a view in code (rather than via the UI), but I've not been able to figure out how to get a dynamic value (a user-specific setting) into the CAML query.
Any pointers gratefully appreciated! And by the way, I am aware of the dogma that folders are bad, and that everything should just be a list. However, having considered the alternatives, I still favour using folders - if I can solve this problem.
Thanks in advance.
Could you create a content type that inherits from Folder that contains a Month column? Then, replace the normal folder content type with your new one on this list. Set the month appropriately, and now your filter would contain the folder as well.
You might like to try using a DataViewWebpart filtered by a form webpart to do this.
Managing the display of the folders and then the folders items when it is clicked on will be a problem. That is one of the reasons for not using folders I guess.
I'm currently experiencing the exact same issue, instead of a simple date, I need to filter based on folder names and then then show those folders on the page. Once they click a folder they will then be able to view the content of that folder.
I haven't found a good solution for this just yet, but for yours, you should be able to simply create a custom CAML query using the contentQueryWebpart.
Something like this:
Further Customize CQWP
But you would do it on the date/time of the folder and nothing else.
Your query would be something like:
<![CDATA[
<Where>
<Gt>
<FieldRef Name="Created" Nullable="True" Type="DateTime"/>
<Value Type="DateTime"><Today /></Value>
</Gt>
</Where>
<OrderBy>
<FieldRef Name="Created" Nullable="True" Type="DateTime"Ascending="FALSE"/>
</OrderBy>]]>
I would add also the name of the folder you're looking for to make sure nothing else gets returned.
Hope this helps. And please do postback if you find another solution.
I think I found your solution - The DataWebPart is actually what helped me....
Using this also was a huge eye opener:
ASP.NET Controls Filter Data View
To summarize it, you can simply populate your dropdown with the month year combo, add the shared Doc library on the page via the designer view, use a 'filter' connection to your ASP.NET dropdown and pronto you have a filter on a per month.
You can also have it default to a certain date using XSL, it's all in the code-view now :)
#Gary
The Controls filter of the DATA view (my 2nd answer) actually does keep the folder hierarchy.
You can have it go into sub-folders if needed, but in your case you're only interested in showing one specific folder correct?
What you're doing is useing SP-designer to do it, I couldn't find a way to do it via the regular webparts.
drag and drop your shared document library in the 'design' view for the page
Click the common task arrow ( > ) and customize the columns you want to show
Still in the common task, apply a filter of choice. What you want to do here is apply a filter on your Month column, so that the Month column is equal to the current month/year, correct?
The filter will only give you a choice to type something in, type the current month, say May 09. then switch to 'code' view
Find the shared document library, and more specifically look for something like:
&lt ;Where&gt ;.... That is the CAML query I had mentioned before. You can do an HTML decode on the whole thing, so that it's a bit more readable.
But in essence, the filter is a simple CAML query.
You want to modify that query, so that your month/year combo is that of the current month/year.
CAML has one feature called <MONTH/> which returns the month in the following format: mm/yyyy (you may need to change the format on your column or create a new one to make it easy on yourself) - Your CAML query should be something a bit like this:
<Where>
<Eq>
<FieldRef Name='Month'/>
<Value Type='Number'><Month/></Value>
</Eq>
</Where>
or
html encoded:
&lt ;Where&gt ;&lt ;Eq&gt ;&lt ;FieldRef Name='Month'/&gt ;&lt ;Value Type='Number'&gt ;&lt ;Month/&gt ;&lt ;/Value&gt ;&lt ;/Eq&gt ;&lt ;/Where&gt ;
The key to this, is that you're only creating a filter at the root level, on the data view. Once they click on the folder, they're just thrown into the document library and can view everything within the folder.
Hope this help!
ps: on the html encoded I had to add spaces before the ';' so you could see the code.
I have worked a great deal with filtering and the SPGridView. Maybe you can get something out of looking into this post on my my blog.
As I said, donĀ“t know if it will help you but have a look.

Sharepoint - A feature creating a list with a workflow : Possible?

I've exported a list definition with Sharepoint Solution Generator.
This list is associated with a workflow. If I search for the name of my workflow in the generated "schema.xml" file, I find XML that looks like this :
<Field DisplayName="publicationWorkflow" Type="WorkflowStatus" Required="FALSE" ID="{2a2504e5-5ad0-4a9f-8bf4-15ca29e49e02}" SourceID="{4ee14f93-1f9b-4dcf-8e50-dd046dfe0905}" StaticName="publicat" Name="publicat" ColName="nvarchar1" RowOrdinal="0" Version="2" WorkflowStatusURL="_layouts/WrkStat.aspx" ReadOnly="TRUE">
<CHOICES>
<CHOICE>Starting</CHOICE>
<CHOICE>Failed on Start</CHOICE>
<CHOICE>In Progress</CHOICE>
<CHOICE>Error Occurred</CHOICE>
<CHOICE>Canceled</CHOICE>
<CHOICE>Completed</CHOICE>
<CHOICE>Failed on Start (retrying)</CHOICE>
<CHOICE>Error Occurred (retrying)</CHOICE>
<CHOICE />
</CHOICES>
</Field>
Then I use a feature to regenerate the list with it's definition from SSG, but the workflow is never made, I have to go to the settings of the list and associate the workflow manually...
So my 1st question is : Is this possible to create a list associated with a workflow using a feature?
And my 2nd : if yes, how?
There is no default way to associate a Workflow to the List Definition, If you want to do you have to follow one of the following option
Write a Feature Receiver and write code to associate the Workflow to the List.
Another option is to create a content type and you can associate a workflow to that content Type using feature.

What is the "Task group" field in a SharePoint Task list for?

Could someone tell me how the field "Task Group" is used in standard SharePoint Task Lists?
I believe it to be a "support" type column. It doesn't really get shown anywhere by default but it's filtered against during the usage of one type of view.
The naming convention they chose isn't very intuitive. Basically when you assign a task to a user account this field is blank. But if you assign a task to a "group", i.e., an active directory security group, this field will get auto populated by SharePoint.
When a SharePoint visitor looks at the task list and chooses the 'my groups' view then this field would be evaluated, e.g., "is visitor a member of this group, if yes, display task". HTH
In your view markup, when you open it in SharePoint designer, add this to the <Where> tag
<Membership Type="CurrentUserGroups">
<FieldRef Name="AssignedTo"/>
</Membership>
and save and it will work perfectly

Resources