DCSIMG
December 2011 - Posts - Choroshin Alex

Choroshin Alex

.NET Developer

December 2011 - Posts

Creating field with formula using CAML XML

Hi Guys,

Here's a quick tip for creating a field with formula using Caml xml.

Suppose you want the DateTime field to show the current date + 30 days.

 <Field ID="{guid}" Name="MyDateTime" DisplayName="ExpiredDate" Type="DateTime" Format="DateOnly"> <DefaultFormula>=Today+30</DefaultFormula>

</Field>

That's all folks :)

Creating List Definition from content type that inherits from event item has some major bugs !

Hi guys,

Recently i needed to create a Calendar list with some additional custom fields.

So i created an content type that inherits from event item with some

 Fields and a list definition from that content type.

The results were unexpected. the calendar list had some major bugs.

For example a lot of the javaScript didn't work, when choosing particular day the "Event Date"

And the "End Date" showed the current date instead of the chosen date, the view of the list was different etc...

I hope in the next version this bug will be fixed but for now fortunately we have a Workaround.

But before we continue i want to say thanks to Itay Shakury for helping me with this bug.

The solution is very simple,

1) Change the List Template type in the List Definition to 106 (Calender list) 

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<ListTemplate

Name="ListDefinition1"

Type="106"

BaseType="0"

OnQuickLaunch="TRUE"

FolderCreation="FALSE"

SecurityBits="11"

Sequence="340"

DisplayName="SharePointProject1 - ListDefinition1"

Description="My List Definition"

Image="/_layouts/images/itevent.png"/>

</Elements>

2) Change the Template type in the List Instance to 106 (Calender list) 

<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<ListInstance Title="SharePointProject1 - ListInstance1"

OnQuickLaunch="TRUE"

TemplateType="106"

Url="Lists/SharePointProject1-ListInstance1"

Description="My List Instance"> </ListInstance> </Elements>

And you will get a working Calendar list with your custom fields. 

That's All folks :)