

It can be useful for creating textures, or patterned backgrounds.
I had not worked with XML comments until joining my current employer. The syntax is pretty simple, and Visual Studio Intellisense handles most of it, but I occasionally find cases where the correct syntax is not obvious. For example, I needed to change an int variable to a nullable int. I updated the variable definition to int?, and changed the XML comment <see cref="int"/> to <see cref="int?"/>. This resulted in a compiler warning: “syntactically incorrect cref attribute 'int?'”. I searched, but could not find a complete listing of the correct syntax for all data types. Eventually, I found enough examples to learn that nullable data types are listed as Nullable{type name}, like <see cref="Nullable{DateTime}"/>, <see cref="Nullable{Int32}"/>, <see cref="Nullable{Bool}"/>, etc.
try
{
this.EnforceConstraints = true;
}
catch
{
foreach(DataTable dt in this.Tables)
{
if (dt.HasErrors)
{
DataRow[] rowErrors = dt.GetErrors();
for (int i = 0; i < rowErrors.GetLength(0); i++)
{
System.Windows.Forms.MessageBox.Show(dt.TableName + ": " + rowErrors[i].RowError.ToString());
}
}
}
}
This isn’t a revolutionary tip, but it’s something that I hadn’t thought to look for and would have been very useful when I was stuck on an old machine.
var accountGuid;
accountGuid = document.getElementById("your fieldname here");
if (IsOnline())
{
// write code for online version here.
}
else
{
var iCount = 0;
var connection = new ActiveXObject("ADODB.Connection");
var connectionString = "Provider=SQLOLEDB;Server=.\\CRM;Database=MSCRM_MSDE;Integrated Security=sspi";
connection.Open(connectionString);
var query = "SELECT count(*) FROM AccountBase WHERE AccountID='" + accountGuid.value + "'";
var rs = new ActiveXObject("ADODB.Recordset");
rs.Open(query, connection, /*adOpenKeyset*/1, /*adLockPessimistic*/2);
rs.moveFirst();
while (!rs.eof) {
iCount = rs.Fields(0).Value;
rs.moveNext();
}
connection.Close();
if (iCount > 0 ) {
//do something useful here
}
else {
//do something else here
}
}
-- Define the Entity to Update
DECLARE @entityname varchar(64);
SET @entityname = 'placeEntityNameHere';
-- Define a GUID for the relationship
-- This is defined here and passed in so that we can access the relationship later
-- and apply special options if needed
DECLARE @TEMP_RelationshipId uniqueidentifier;
-- Add the ActivityPointer Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'ActivityPointer', '_ActivityPointers', @TEMP_RelationshipId;
-- Add the Appointment Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'Appointment', '_Appointments', @TEMP_RelationshipId;
-- Add the Email Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'Email', '_Emails', @TEMP_RelationshipId;
-- Add the Fax Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'Fax', '_Faxes', @TEMP_RelationshipId;
-- Add the Letter Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'Letter', '_Letters', @TEMP_RelationshipId;
-- Add the PhoneCall Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'PhoneCall', '_PhoneCalls', @TEMP_RelationshipId;
-- Add the ServiceAppointment Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'ServiceAppointment', '_ServiceAppointments', @TEMP_RelationshipId;
-- Add the Task Relationship
SET @TEMP_RelationshipId = NEWID();
EXEC dbo.AddCrmRelationship @entityname, 'Task', '_Tasks', @TEMP_RelationshipId;
go
<attribute PhysicalName="Ffs_fieldtomodify">
<Type>nvarchar</Type>
<Length>150</Length>
<ValidForCreateApi>1</ValidForCreateApi>
<ValidForUpdateApi>1</ValidForUpdateApi>
<ValidForReadApi>1</ValidForReadApi>
<IsCustomField>1</IsCustomField>
<DisplayMask>PrimaryNameValidForAdvancedFindValidForFormValidForGrid</DisplayMask>
<Description>The name of the custom entity.</Description>
</attribute>
<field name="ffs_fieldtomodify" requiredlevel="required" maxlength="75" format="text">
<displaynames>
<displayname description="Field To Modify" languagecode="1033" />
</displaynames>
</field>
4. Save the XML, import it into CRM, and publish customizations. (At this point, CRM will show the new length but the SQL tables have not been updated. So, if you try to save a value that is too long you will get a SQL exception message. To solve this, continue on.)
5. Modify the field’s length in the
6. To get the field length to display correctly in the CRM metadata browser, update the Attribute table in the
select * from attribute where [name] = 'ffs_fieldtomodify'