Add-PnPDataRowsToProvisioningTemplate with empty -fields parameter not working? - sharepoint

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

Related

Ms Dynamics CRM custom workflow get visible attributes from form using c#

How to get visible attributes from entity form using c# in custom workflow?
Any idea please share!
It's a PITA but it's doable.
retrieve the form you want to process from the systemform entity (you want the formxml attribute)
the formxml attribute contains the form definition, it's encoded (< is written as < and so on) xml format.
Inside the formxml contents, a field looks like this:
<cell id="(guid)" labelid="(guid)" showlabel="true" locklevel="0" visible="false">
<labels>
<label description="(field label)" languagecode="1033" />
</labels>
<control id="(field name)" classid="(guid)" datafieldname="(field name)" disabled="false">
parse the xml, looking for cell elements which do not have visible attribute (it's only there if the field is hidden)
you might have to narrow the list down through further searches in xml (not 100% positive about what i.e. a subgrid would look like) but I have no direct experience with this kind of logic so I can't pinpoint each and every corner case
Pain point: You won't be able to tell if a field visibility has been toggled through javascript
What do you mean visible attributes? You mean attributes with a value or attributes showed in the form? If it's the second the only way that you have to keep track of that is use a text field and use some code to identify what is active.
ex. create a text field
and write in it all the fields that are visible ex name and surname:
"name","surname"
You can manipulate this with javascript and business rules to keep the list of fields updated at every time for each record. In the code behind you just need to read for the text field and manipulate the magic string.
It's not a really nice operation, but is the only way i can see to keep track of what fields are shown on the form.

Orchard Create Projection or Search Based on Filtered Dropdown Selections

I have, what I think is, a simple feature that I am trying to add to my Orchard (1.6) site, but I can't find any tutorials or instructions on how to do it. I have a custom type called "Office" and each office has a custom field called "State" indicating which state the office is in. I actually designed my Offices as a custom part in code with specific properties such as State on it, but I "think" it's the same as if I added the State through the Admin interface as a field on the Office content part.
Now, I can create a basic projection to show all the offices with a simple filter of "Content with type Office" to display all offices. However, what I want to do now is to have a drop down list at the top of the page that says "Filter by: [-SELECT STATE-]" with a list of all 50 states. When the user selects a state, the page should refresh and display just the offices in that state.
This is where I'm stuck. Should I do this through the code, or can I do this through the Admin UI? If through the code, should I model it after the Orchard.Search module (which I tried to do, but I am completely lost). If I can do it through the UI, do I use projections? If so, do I have to create 50 separate projections (one for each state)? That seems extremely time consuming to create and maintain.
Any help is GREATLY appreciated!
FYI, the site at http://ktowneric.com/listings/search (which uses Orchard) is very similar what I am looking for, and the developer stated he used projections, but I can't seem to figure out how he did it.
You can definitely use a projection. If you notice when you use the search function on the page you referenced, the inputs are formed into query string values. You can use tokens to grab the values from query strings to use in your projection filter. For example, if you're using fields as you stated, then you just add a filter for that field and in the value field use {Request.QueryString:State}. Or, replace "State" with whatever key you're using for the query string value.
That solves your projection issue. You will need to build a search form that would look something like this...
<form action="/search-results" method="Get">
<select name="State">
<option value="OH">Ohio</option>
...all the states...
</select>
<input type="submit" value="Search" />
</form>
"/search-results" could be a projection page or any content that has the projection widget present. You could build the form as a widget that you can place somewhere, or for testing purposes, you could just paste this html into an html widget to try it out.

Create custom field in SharePoint 2007 New Item Form

I want to modify a NewForm.aspx in a Task List to allow a custom string to be built. I have two fields, ID and Assigned To, and want create a third field that concatenates the two. Unfortunately, I cannot use the Assigned To column value in a calculated column.
I thought that I might be able to modify the form in SPD, but haven't a clue how to actually modify the field. This is what is present:
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New"
FieldName="Task_x0020_ID" __designer:bind="{ddwrt:DataBind('i',concat
('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string
(#ID)),'#Task_x0020_ID')}"/>
Any suggestions (not involving career changes) to get me started?
Thanks!
You will need to customize the NewForm.aspx using SharePoint Designer. A guide to doing this can be found here: http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-custom-list-form-HA010119111.aspx#BM2
and here: http://kalsing.blogspot.com/2006/11/create-custom-list-form-for-sharepoint.html
Then to do the concatenation you are suggesting I would use Javascript to set the value of a field nested in a <tr> with class="hiddenRow". You can find some information about using Javascript to adjust your values on this page: http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx
A great place to find some examples of how this is done is to install one of the fab 40 (the bug Database for example) and then open the custom forms for those lists in SharePoint Designer.
I know that is a broad answer and not a specific how-to, but it is a big question involving many steps. Hopefully the above links point you in the right direction.
You could just use SPD to create a simple workflow that concatenates the two fields together (Build a dynamic string) and sets your new field (set field in current item) whenever the item is created.

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.

Resources