SharePoint PnP - Adding fields to default view - sharepoint-2016

I’m using the SharePoint PnP templates to deploy a list instance to SharePoint 2016. Is it possible to make the field “TheName” part of the default view or a particular view using an attribute?
Below I’ve set the “TheName” field attributes Viewable="true" ShowInDisplayForm="true" ShowInViewForms="true" but that has not resulted in “TheName” being part of the default view. Below is the xml for the list instance:
<pnp:ListInstance Title="Application" Description="" EnableAttachments="true" DocumentTemplate="" TemplateType="100" Url="Lists/Application" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" ContentTypesEnabled="true" EnableFolderCreation="true">
<pnp:ContentTypeBindings>
<pnp:ContentTypeBinding ContentTypeID="0x0109413FF39DA2049E08C8B9564402E3562" Default="true" />
</pnp:ContentTypeBindings>
<pnp:Fields>
<pnp:Field Type="Text" DisplayName="TheName" StaticName="TheName" Name="TheName" Default="true" ID="{db2beb10-5325-434d-a559-691e340a4fea}" Viewable="true" ShowInDisplayForm="true" ShowInViewForms="true" />
</pnp:Fields>
</pnp:Views>
</pnp:ListInstance>
I can explicitly create/set the default view to include “TheName” but then I end up having to list all the fields that are part of the list including the ones which come from a site content type. This can become a hassle to maintain. The below list instance xml displays “TheName” as part of the default view:
<pnp:ListInstance Title="Application" Description="" EnableAttachments="true" DocumentTemplate="" TemplateType="100" Url="Lists/Application" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" ContentTypesEnabled="true" EnableFolderCreation="true">
<pnp:ContentTypeBindings>
<pnp:ContentTypeBinding ContentTypeID="0x0109413FF39DA2049E08C8B9564402E3562" Default="true" />
</pnp:ContentTypeBindings>
<pnp:Fields>
<pnp:Field Type="Text" DisplayName="TheName" StaticName="TheName" Name="TheName" Default="true" ID="{db2beb10-5325-434d-a559-691e340a4fea}" Viewable="true" ShowInDisplayForm="true" ShowInViewForms="true" />
</pnp:Fields>
<pnp:Views>
<View DisplayName="All Items">
<ViewFields>
<FieldRef Name="TheName" />
<FieldRef Name="Title" />
<FieldRef Name="ApplicationId" />
<FieldRef Name="Case" />
</ViewFields>
</View>
</pnp:Views>
</pnp:ListInstance>

Related

How to add attributes to input fields in JSP

How can I add the following attributes:
placeholder="text here"
required
data-parsley-type="number"
checked (only for he radio)
To the following inputs in a form:
<html:text property="text" value="text" />
<html:radio property="radio" value="1" />
<html:select property="text" value="1" />

PropelORM+PostgreSQL: How do I define an SQL-like CHECK constraint on a column in 'schema.xml'?

A little snippet of a database schema I'm trying to define in my "schema.xml" file:
<table name="hotelroom" phpName="hotelroom">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="room_number" type="varchar" size="10" required="true" />
<column name="price" type="numeric" defaultValue="1000" required="true" />
<unique>
<unique-column name="room_number" />
</unique>
</table>
In PostgreSQL for that "price" column I would've written CHECK (price > 0::numeric),but I can't seem to find any way to achieve this here.I've checked the documentation (http://propelorm.org/documentation/reference/schema.html), but couldn't find anything on this.
Thank you for the time.
You're using v1, but from the doc link above, looks like you're using v2,
I think you're looking for the GreaterThan which is only available from v2 onwards.
<behavior name="validate">
<parameter name="rule1" value="{column: price, validator: GreaterThan, options: {value: 0, message=Price is not valid}}" />
</behavior>

How to load entities of which a property of type PersistentList contains one or more values from array parameter?

My model contain the following enumeration and entity:
<cf:enumeration name="Language" usePersistenceDefaultValue="false">
<cf:enumerationValue name="EN" value="1" default="true" />
<cf:enumerationValue name="NL" value="2" />
<cf:enumerationValue name="DE" value="3" />
</cf:enumeration>
<cf:entity name="Person" >
<cf:property name="Id" key="true" />
<cf:property name="Languages" typeName="CodeFluent.Runtime.Utilities.PersistentList<Language>">
<cf:message class="_doc">The languages that the person speaks</cf:message>
</cf:property>
<cf:method name="LoadPersonThatSpeaksOneOrMoreLanguages" checkLevel="None" memberAttributes="Public" >
<cf:body language="tsql" text="load(Language[] languages) from Person where Languages in (#languages)" />
</cf:method>
</cf:entity>
The method LoadPersonThatSpeaksOneOrMoreLanguages should return all persons that speak one or more of the provided languages.
The generated stored procedure for this method seems not to be correct:
ALTER PROCEDURE [dbo].[Person_LoadPersonThatSpeaksOneOrMoreLanguages]
(
#languages [dbo].[cf_type_Person_LoadPersonThatSpeaksOneOrMoreLanguages_0] READONLY,
#_orderBy0 [nvarchar] (64) = NULL,
#_orderByDirection0 [bit] = 0
)
AS
SET NOCOUNT ON
DECLARE #_c_languages int; SELECT #_c_languages= COUNT(*) FROM #languages
SELECT DISTINCT [Person].[Person_Id], ...
FROM [Person]
WHERE [Person].[Person_Languages] IN (((SELECT * FROM #languages)))
Question 1:
How can I achieve the desired result?
Should I create a Language entity and specify an 1:n association between Person and Language? I prefer not to have a Language entity.
Or can I specify that the Languages property must be converted to the same type as the table-valued-parameter (cf_type_Person_LoadPersonThatSpeaksOneOrMoreLanguages_0)?
Question 2:
The produced PersonCollection class contains the method LoadPersonThatSpeaksOneOrMoreLanguages. The parameter of this method is of type Language[]. Instead of an array I want an IEnumerable<Language>. How can I specify this in my XML model?
Question 1
The PersistentList is designed to store a collection of simple values (int, string, enum, ...), but not to query them directly in SQL. Indeed the PersistentList is translated to a NVARCHAR column in the database and this column contains values like EN|NL (pipe separated values). The database engine does not know how to extract single values from the string. Maybe you can use the cf_SplitString function to create a table from the column value and do what you want with it, but it does not seem to be the simplest solution...
Depending of your need you can use a multi-valued enumeration:
<cf:enumeration name="Language" flags="true">
<cf:enumerationValue name="Unspecified" /> <!-- value=0 -->
<cf:enumerationValue name="EN" /> <!-- value=1 -->
<cf:enumerationValue name="NL" /> <!-- value=2 -->
<cf:enumerationValue name="FR" /> <!-- value=4 -->
</cf:enumeration>
You can use them with CFQL:
-- Load Persons that speak the specified language
LOAD(Languages) WHERE (Languages & #Languages) = #Languages
-- Load Persons that speak at least one of the specified language
LOAD(Languages) WHERE (Languages & #Languages) <> 0
Of course the latest possibilities is to create a Language entity and use Table Valued Parameters.
http://blog.codefluententities.com/2014/07/16/persistent-list/
http://www.softfluent.com/documentation/Enumerations_Overview.html
Question 2
From the official blog of CodeFluent Entities:
Take what I say with a grain of salt as you are dealing with a topic I have looked into but never implemented. With that said another approach would be to use a multi-valued enumeration (flag)
http://blog.codefluententities.com/2013/05/29/using-flags-enumeration-with-aspnet-mvc-and-codefluent-entities
Using this approach you would create a relationship between the entity and the enumeration instead of making the Languages property a persistent list.
The following mostly works. When using the Modeler to create instances I was not able to select certain combinations of languages. Don't know if this was due to my inexperience in working with and setting up flag enumeration or if there is a flaw in the modeler. But I did manage to create the method and that part appears to be working.
<cf:enumeration name="Language" multivalue="true" usePersistenceDefaultValue="false" namespace="Demo1" categoryPath="/Demo1">
<cf:enumerationValue name="Unspecified" default="true" />
<cf:enumerationValue name="EN" />
<cf:enumerationValue name="NL" />
<cf:enumerationValue name="DE" />
</cf:enumeration>
<cf:entity name="Person" namespace="Demo1">
<cf:property name="Id" key="true" />
<cf:property name="Languages" usePersistenceDefaultValue="false" typeName="{0}.Language" />
<cf:property name="FirstName" />
<cf:property name="LastName" />
<cf:instance>
<cf:instanceValue name="Id">d13447c6-a709-4c87-891d-e83674821915</cf:instanceValue>
<cf:instanceValue name="FirstName">Jon</cf:instanceValue>
<cf:instanceValue name="LastName">Smith</cf:instanceValue>
</cf:instance>
<cf:instance>
<cf:instanceValue name="Id">77e3730c-2cc3-457d-8bc0-d9a5e224b96a</cf:instanceValue>
<cf:instanceValue name="FirstName">Sam</cf:instanceValue>
<cf:instanceValue name="Languages">DE, SP</cf:instanceValue>
<cf:instanceValue name="LastName">Newman</cf:instanceValue>
</cf:instance>
<cf:method name="LoadPersonThatSpeaksOneOrMoreLanguages" body="LOAD() WHERE Languages > 0" />
As I said take what I'm saying with a grain of salt. I ended up using an entity instead of an enumeration but only because that was what I was more familar with and had a deadline.

Cannot filter by string from remote url

Created a WCF Data Service to pull data from Oracle database and when debugging in VS I can use the ?$filter syntax to filter returned sets.
However, using the remote url I cannot.
Point to note: I can filter by integers and dates, however I cannot filter by strings.
Also, I cannot filter by any string field in code. The filter is ignored.
Sample item below:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://localhost:61905/CampaignerSVC.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Contacts</title>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts</id>
<updated>2015-04-29T15:06:48Z</updated>
<link rel="self" title="Contacts" href="Contacts" />
<entry>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts(23517014)</id>
<title type="text"></title>
<updated>2015-04-29T15:06:48Z</updated>
<author>
<name />
</author>
<link rel="edit" title="ContactList" href="Contacts(23517014)" />
<category term="Campaigner_DAL_WCF.ContactList" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:LicenseNumber m:type="Edm.Int32">23517014</d:LicenseNumber>
<d:ClientCode>2000</d:ClientCode>
<d:ClientName>Doodler</d:ClientName>
<d:ClientMnemonic>DD</d:ClientMnemonic>
<d:LastName>Kerr</d:LastName>
<d:FirstName>Rover</d:FirstName>
<d:MiddleName>Frank</d:MiddleName>
<d:Title>Mr.</d:Title>
<d:PreferredFirstName>Rover</d:PreferredFirstName>
<d:PreferredMiddleName>Frank</d:PreferredMiddleName>
<d:CompanyName m:null="true" />
<d:JobTitle m:null="true" />
<d:Gender>M</d:Gender>
<d:DateOfBirth m:type="Edm.DateTime">1947-04-27T00:00:00</d:DateOfBirth>
<d:PrimaryChapterCode m:type="Edm.Int16">400</d:PrimaryChapterCode>
<d:AlternateChapterCode m:type="Edm.Int16" m:null="true" />
<d:MainAddrStreetNo>121</d:MainAddrStreetNo>
<d:MainAddrLine1>So Crescent</d:MainAddrLine1>
<d:MainAddrLine2 m:null="true" />
<d:MainAddrLine3 m:null="true" />
<d:MainAddrCity>MAICK</d:MainAddrCity>
<d:MainAddrProvCode>ON</d:MainAddrProvCode>
<d:MainAddrProv>Ontario</d:MainAddrProv>
<d:MainAddrPostalCode>KB7</d:MainAddrPostalCode>
<d:MainAddrCountryCode>CA</d:MainAddrCountryCode>
<d:MainAddrCountry>Canada</d:MainAddrCountry>
<d:MainPhoneNum>610-000-0703</d:MainPhoneNum>
<d:MainPhoneExt m:null="true" />
<d:MainFaxNum m:null="true" />
<d:MainEmailAddr>someone#rogers.com</d:MainEmailAddr>
<d:CellPhoneNum m:null="true" />
<d:ChangeType>D</d:ChangeType>
<d:EventTimeStamp m:type="Edm.DateTime">2015-04-29T02:40:02</d:EventTimeStamp>
<d:PrivacyIndicator>N</d:PrivacyIndicator>
</m:properties>
</content>
</entry>
</feed>
You can filter by string also by using the string in quotes like below-
'string'
Ok, so the issue was that I had created a class to store the results from the entity model.
Although I had a DataKey value specified, the problem was that the field I specified was not unique, therefore the filters were being ignore (or only the first matching record was filtered).
What I had to do was decorate the class with a composite DataKey.

Orchard cms adding data-mediapicker-uploadpath to a custom type

I have created a custom type in orchard cms, that has a two column lay out
It has 2 header text fileds and 2 content HTML flavour fileds
Heres the migration :
public class MigrationTwoColumnPageType : DataMigrationImpl
{
public int Create()
{
// Define the project type
ContentDefinitionManager.AlterTypeDefinition("TwoColumnPage", cfg => cfg
.WithSetting("Stereotype", "Content")
.CommomPart()
.AutoroutePart()
.WithPart("TitlePart")
.WithPart("MenuPart")
.WithPart("TagsPart")
.WithPart("PublishLaterPart")
.WithPart("TwoColumnPage")
.Creatable()
.Draftable());
return 1;
}
public int UpdateFrom1()
{
// Define project part - having a part with the same name will create fields in the project type
ContentDefinitionManager.AlterPartDefinition("TwoColumnPage", builder => builder
.TextField("Column1Title", Flavour.Large)
.TextField("Column1Text", Flavour.Html)
.TextField("Column2Title", Flavour.Large)
.TextField("Column2Text", Flavour.Html)
.Attachable());
return 2;
}
}
NOTE: TextField is a custom extension method to make things less verbose
When I try and use the media picker to up load an image into one of these content fields I get a folder not found error, - I have traced this back to the media path on the Request querystring not being set
// media directory to save uploaded files into
var mediaPath = Request["uploadpath"];
in ../../Orchard.MediaPicker/Views/admin/Tab_Url.cshtml
Is there some way to set this using filed settings ?
Seems to work fine for any pages I create, but custom types .... how do I set this value ?
UPDATE
Heres the xml meta data for a page...
<!--Exported from Orchard-->
<Orchard>
<Recipe>
<Name>Generated by Orchard.ImportExport</Name>
<Author>admin</Author>
</Recipe>
<Metadata>
<Types>
<Page ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" TypeIndexing.Included="true" DisplayName="Page">
<NavigationPart />
<CommonPart DateEditorSettings.ShowDateEditor="true" />
<PublishLaterPart />
<TitlePart />
<AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-page'}]" AutorouteSettings.DefaultPatternIndex="0" />
<BodyPart />
<TagsPart />
<LocalizationPart />
</Page>
</Types>
<Parts>
<NavigationPart ContentPartSettings.Attachable="True" />
<CommonPart ContentPartSettings.Attachable="True" />
<PublishLaterPart ContentPartSettings.Attachable="True" />
<TitlePart ContentPartSettings.Attachable="True" />
<AutoroutePart ContentPartSettings.Attachable="True" />
<BodyPart ContentPartSettings.Attachable="True" BodyPartSettings.FlavorDefault="html" />
<TagsPart ContentPartSettings.Attachable="True" />
<LocalizationPart />
</Parts>
</Metadata>
</Orchard>
Here's the XML meta for my custom type, using TestFiledSetting instead of BodyPartSetting
<!--Exported from Orchard-->
<Orchard>
<Recipe>
<Name>Generated by Orchard.ImportExport</Name>
<Author>admin</Author>
</Recipe>
<Metadata>
<Types>
<TwoColumnPage Stereotype="Content" OwnerEditorSettings.ShowOwnerEditor="false" ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" DisplayName="Two Column Page">
<CommonPart />
<AutoroutePart AutorouteSettings.PatternDefinitions="[{Name:'/Title', Pattern: '/{Content.Slug}', Description: 'my-page'}]" />
<TitlePart />
<MenuPart />
<TagsPart />
<PublishLaterPart />
<TwoColumnPage />
</TwoColumnPage>
</Types>
<Parts>
<CommonPart ContentPartSettings.Attachable="True" />
<AutoroutePart ContentPartSettings.Attachable="True" />
<TitlePart ContentPartSettings.Attachable="True" />
<MenuPart ContentPartSettings.Attachable="True" />
<TagsPart ContentPartSettings.Attachable="True" />
<PublishLaterPart ContentPartSettings.Attachable="True" />
<TwoColumnPage ContentPartSettings.Attachable="True">
<Column1Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
<Column1Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
<Column2Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
<Column2Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
</TwoColumnPage>
</Parts>
</Metadata>
</Orchard>
No mention of data-mediapicker-uploadpath in either. I'm still lost!