Customizing NewForm.aspx and EditForm.aspx pages for Lists.


Recently, I was assigned a task to customize the NewForm.aspx and EditForm.aspx for a particular list. The list was part of a site definition generated using SharePoint Solution Generator.

The reason we wanted to customize the page was because we wanted one custom field to be added (drop down list) that would display all the content types in that site.

You can find the sample project and related files over here

Link:- https://nishantrana.me/wp-content/uploads/2010/06/sharepointproject.doc

Please rename the file from SharePointProject.doc to SharePointProject.zip after downloading it.

Bye..

LookUp for Site Definition in SharePoint.


Suppose we have created a site definition for an existing Site having two lists and one of the lists uses a lookup column that points to the other list.

Now if we are creating site using that site definition we will find our lookup column missing in the list.

If we check the schema.xml for our list, we will find our lookup field to be commented.

LookUp

To get it working ,  we need to define the field in the following manner

Original

<Field Type="Lookup" DisplayName="myLookUp" Required="FALSE" List="{72424dd2-9030-408a-97c9-8482d9d81204}" ShowField="Title" UnlimitedLengthInDocumentLibrary="FALSE" ID="{f50277a0-4da5-46d3-8e60-284c729a3eb8}" SourceID="{07e7832d-45df-4f69-b5bb-e31c5107c5ca}" StaticName="myLookUp" Name="myLookUp" ColName="int1" RowOrdinal="0" />

It should be modified to

<Field Type="Lookup"
DisplayName="myLookUp"
Required="FALSE"
 List="Lists/SecondList"
ShowField="Title"
ID="{f50277a0-4da5-46d3-8e60-284c729a3eb8}"
StaticName="myLookUp" Name="myLookUp" ></Field>

SecondList :- The name of the other list.

Check this wonderful post

http://www.mtelligent.com/journal/2007/10/14/adding-back-lookup-columns-in-the-provisioning-handler.html

 

Bye…

Invalid data has been used to update the list item. The field you are trying to update may be read only.


I got this error while updating an splistitem. It was coming while trying to update “Person or Group” type column.

This is the correct way to update the column of type “Person or Group”.

itemApprovalAssignment["Title"] = txtTitle.Text.Trim();
                    itemApprovalAssignment["Assign_x0020_To"] = oweb.EnsureUser(peAssignTo.CommaSeparatedAccounts);

i.e. to use EnsureUser method.

Bye..

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))


I was getting the above error while deploying the Site Definition in SharePoint. The unique thing about this error was that after some time it used to get resolved itself.

Then while searching for it i found the following solution for it which is to Stop the Indexing Service.

And it really worked.

Bye..

Updating a Picklist Attribute from within a Plugin


Hi,

Just a sample code for updating a picklist attribute for an entity instance.

  public void  Execute(IPluginExecutionContext context)
{
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties["Target"];
if (entity.Name == "new_test")
{
// Post Create event so get the guid from Output Parameters
Guid testId = (Guid)context.OutputParameters.Properties["id"];

ICrmService crmService = context.CreateCrmService(true);
DynamicEntity myTest = new DynamicEntity();
myTest.Name = "EntityName";

// Set the key property
KeyProperty myTestGuid = new KeyProperty();
myTestGuid.Name = "EntityPrimaryKeyID";
Key myTestKey=new Key();
myTestKey.Value = testId;
myTestGuid.Value = myTestKey;
myTest.Properties.Add(myTestGuid);

// Picklist property to be updated
PicklistProperty myPP = new PicklistProperty();
myPP.Name = "new_picklist";
myPP.Value = new Picklist();
myPP.Value.name = "nameOfThePicklistValue";
// picklist value
myPP.Value.Value = 2;
myTest.Properties.Add(myPP);
try
{
    crmService.Update(myTest);
}
catch (SoapException ex)
{

    TextWriter log1 = TextWriter.Synchronized(File.AppendText(@"C:\g.txt"));
    log1.WriteLine("MyMessage exception :-" + ex.Detail.InnerXml );
    log1.Close();
}
}
}
}

 

 

Bye…

Resource (.resx) files in Custom Content Type


These are the steps we need to follow

Suppose this the custom content type

<?xml version=”1.0″ encoding=”utf-8″?>
<Elements Id=”555705e7-e69f-4670-a972-c7bab158f935″ xmlns=”http://schemas.microsoft.com/sharepoint/”>
<ContentType ID=”0x010100923d6eee64764f08baa6903fb9095a6c”
Name=”GContentType”
Group=”Development”
Description=”Developing Content Type”
Version=”0″>
<FieldRefs>
<FieldRef ID=”{38ae2eb9-fca6-448b-9c8d-47abfeb7fbb5}” Name=”GContentTypeField” />
</FieldRefs>
</ContentType>
<Field ID=”{38ae2eb9-fca6-448b-9c8d-47abfeb7fbb5}”
Type=”Text”
Name=”GContentTypeField”
DisplayName=”$Resources:GED,Mission”
StaticName=”GContentTypeField”
Hidden=”FALSE”
Required=”FALSE”
Sealed=”FALSE” />
</Elements>

Here GED would be the name of resource files and mission is the Key Name.

Resource

GED.resx file needs to be deployed to ..12\Resources directory.

And in the feature.xml set

DefaultResourceFile=”GED”

http://innersharepoint.blogspot.com/2009/10/how-to-locolize-site-columns-using.html

http://blogs.msdn.com/b/joshuag/archive/2009/03/07/using-resource-files-resx-when-developing-sharepoint-solutions.aspx

Bye..