Today I tried to migrate a custom CRM 4.0 SQL report to the a CRM 2013 SQL report.
In the report designer I hit the preview button and received the following error:
TITLE: Microsoft SQL Server Report Designer
------------------------------
An error occurred while executing the query.
An insufficient number of arguments were supplied for the procedure or function dbo.fn_GetLocalizedLabel.
OK, this means the SQL function "fn_GetLocalizedLabel" in CRM 4.0 used to have one parameter less than in CRM 2011 or CRM 2013.
After comparing the paramter signatures with the SQL database version I found this definition:
The missing parameter was the "LabelTypeCode".
So I thought what in the world do I have to put in here??
I search in Google and even the CRM SDK documentation does not tell us what this parameter means.
Finally, my last resort is usually to check the CRM assemblies with a Reflector or JustDecompile tool to find out how to deal with this.
Immediately I found this:
Checking the LocalizedLabelView in the database I only found this information regarding the Labels (truncated data and columns for readability):
As you can see the LabelTypeCode contains integer values. But without the enum displayed above the table information would be meaningless as we do not know the purpose of the integer values.
Short reminder:
Enum values start to count from 0.
Meaning that Entity has the number 0, Attribute is 1 ...
This maps to this table:
I hope this helps you to get a better understanding as well in any case you ever need to work with the LabelTypeCodes.
In the report designer I hit the preview button and received the following error:
TITLE: Microsoft SQL Server Report Designer
------------------------------
An error occurred while executing the query.
An insufficient number of arguments were supplied for the procedure or function dbo.fn_GetLocalizedLabel.
OK, this means the SQL function "fn_GetLocalizedLabel" in CRM 4.0 used to have one parameter less than in CRM 2011 or CRM 2013.
After comparing the paramter signatures with the SQL database version I found this definition:
function [dbo].[fn_GetLocalizedLabel] (
@ObjectId uniqueidentifier,
@ColumnName nvarchar(255),
@LabelTypeCode int,
@LanguageCode int
)
returns nvarchar(255)
as
begin
declare @LocalizedLabel nvarchar(255)
begin
select @LocalizedLabel = l.Label
from LocalizedLabelView l
where @ObjectId = l.ObjectId
and @LanguageCode = l.LanguageId
and @ColumnName = l.ObjectColumnName
and @LabelTypeCode = l.LabelTypeCode
end
return @LocalizedLabel
end
@ObjectId uniqueidentifier,
@ColumnName nvarchar(255),
@LabelTypeCode int,
@LanguageCode int
)
returns nvarchar(255)
as
begin
declare @LocalizedLabel nvarchar(255)
begin
select @LocalizedLabel = l.Label
from LocalizedLabelView l
where @ObjectId = l.ObjectId
and @LanguageCode = l.LanguageId
and @ColumnName = l.ObjectColumnName
and @LabelTypeCode = l.LabelTypeCode
end
return @LocalizedLabel
end
The missing parameter was the "LabelTypeCode".
So I thought what in the world do I have to put in here??
I search in Google and even the CRM SDK documentation does not tell us what this parameter means.
Finally, my last resort is usually to check the CRM assemblies with a Reflector or JustDecompile tool to find out how to deal with this.
Immediately I found this:
namespace Microsoft.Crm.Metadata
{
public enum LabelTypeCode
{
[EnumIntroducedVersion("5.0.0.0", true)]
Entity,
[EnumIntroducedVersion("5.0.0.0", true)]
Attribute,
[EnumIntroducedVersion("5.0.0.0", true)]
AttributePicklistValue,
[EnumIntroducedVersion("5.0.0.0", true)]
EntityRelationshipRole,
[EnumIntroducedVersion("5.0.0.0", true)]
SavedQuery,
[EnumIntroducedVersion("5.0.0.0", true)]
Form,
[EnumIntroducedVersion("5.0.0.0", true)]
FormTab,
[EnumIntroducedVersion("5.0.0.0", true)]
FormSection,
[EnumIntroducedVersion("5.0.0.0", true)]
FormCell,
[EnumIntroducedVersion("5.0.0.0", true)]
SavedQueryVisualization,
[EnumIntroducedVersion("5.0.0.0", true)]
OptionSet,
[EnumIntroducedVersion("5.0.0.0", true)]
Solution,
[EnumIntroducedVersion("5.0.0.0", true)]
Publisher,
[EnumIntroducedVersion("5.0.0.0", true)]
Ribbon,
[EnumIntroducedVersion("5.0.0.0", true)]
TimeZoneDefinition,
[EnumIntroducedVersion("5.0.0.0", true)]
TimeZoneLocalizedName,
[EnumIntroducedVersion("5.0.0.0", true)]
WebResource,
[EnumIntroducedVersion("5.0.0.0", true)]
ManagedProperty,
[EnumIntroducedVersion("5.0.0.0", true)]
ComplexControl,
[EnumIntroducedVersion("6.0.0.0", true)]
Workflow
}
}
{
public enum LabelTypeCode
{
[EnumIntroducedVersion("5.0.0.0", true)]
Entity,
[EnumIntroducedVersion("5.0.0.0", true)]
Attribute,
[EnumIntroducedVersion("5.0.0.0", true)]
AttributePicklistValue,
[EnumIntroducedVersion("5.0.0.0", true)]
EntityRelationshipRole,
[EnumIntroducedVersion("5.0.0.0", true)]
SavedQuery,
[EnumIntroducedVersion("5.0.0.0", true)]
Form,
[EnumIntroducedVersion("5.0.0.0", true)]
FormTab,
[EnumIntroducedVersion("5.0.0.0", true)]
FormSection,
[EnumIntroducedVersion("5.0.0.0", true)]
FormCell,
[EnumIntroducedVersion("5.0.0.0", true)]
SavedQueryVisualization,
[EnumIntroducedVersion("5.0.0.0", true)]
OptionSet,
[EnumIntroducedVersion("5.0.0.0", true)]
Solution,
[EnumIntroducedVersion("5.0.0.0", true)]
Publisher,
[EnumIntroducedVersion("5.0.0.0", true)]
Ribbon,
[EnumIntroducedVersion("5.0.0.0", true)]
TimeZoneDefinition,
[EnumIntroducedVersion("5.0.0.0", true)]
TimeZoneLocalizedName,
[EnumIntroducedVersion("5.0.0.0", true)]
WebResource,
[EnumIntroducedVersion("5.0.0.0", true)]
ManagedProperty,
[EnumIntroducedVersion("5.0.0.0", true)]
ComplexControl,
[EnumIntroducedVersion("6.0.0.0", true)]
Workflow
}
}
Checking the LocalizedLabelView in the database I only found this information regarding the Labels (truncated data and columns for readability):
LocalizedLabelId
|
LocalizedLabelRowId
|
LanguageId
|
ObjectId
|
ObjectColumnName
|
Label
|
LabelTypeCode
|
ComponentState
|
IsManaged
|
E9158B76-…
|
7EDC933C-…
|
2052
|
C341B506-…
|
DisplayName
|
其他
|
2
|
0
|
1
|
F4F48DB1-…
|
5B90A8A8-…
|
2052
|
CDA38168-…
|
Description
|
地址 1 的送货方式。
|
10
|
0
|
1
|
C97111AD-…
|
063C23C1-…
|
1033
|
8734A095-…
|
Description
|
Position
of the Sdk
message response field
|
1
|
0
|
1
|
As you can see the LabelTypeCode contains integer values. But without the enum displayed above the table information would be meaningless as we do not know the purpose of the integer values.
Short reminder:
Enum values start to count from 0.
Meaning that Entity has the number 0, Attribute is 1 ...
This maps to this table:
LabelTypeCode
|
Integer
|
Entity
|
0
|
Attribute
|
1
|
AttributePicklistValue
|
2
|
EntityRelationshipRole
|
3
|
SavedQuery
|
4
|
Form
|
5
|
FormTab
|
6
|
FormSection
|
7
|
FormCell
|
8
|
SavedQueryVisualization
|
9
|
OptionSet
|
10
|
Solution
|
11
|
Publisher
|
12
|
Ribbon
|
13
|
TimeZoneDefinition
|
14
|
TimeZoneLocalizedName
|
15
|
WebResource
|
16
|
ManagedProperty
|
17
|
ComplexControl
|
18
|
Workflow
|
19
|
I hope this helps you to get a better understanding as well in any case you ever need to work with the LabelTypeCodes.
thank you very much!
ReplyDeletebut can you tell me where i can find FormCell objects in database?
i have localizedlabelview.LabelTypeCode = 8 :)
well, we have found that guids ('unknown' objectIds) in SystemForm.FormXml field
ReplyDeletethere's xml markup of entity form, and 'cell id' equals that objectid in LocalizedLabel view
unfortunately not really easy to work with such xml :(
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteok.
ReplyDeletegot table like that:
declare @x xml = (select top 1 cast (formxml as xml) from SystemForm where formid = '1E7579EC-1A39-4D35-A38F-1D6A374D6106')
SELECT
t.c.value(N'@id', N'nvarchar(50)') AS Id
,C.N.value('@id', 'nvarchar(500)') as attrName
FROM
@x.nodes(N'//cell') t(c)
outer apply t.c.nodes('control') as C(N)
great you found a solution
ReplyDelete