Skip to main content

Power Automate: SharePoint Copy file action fails on file names with a plus (+) sign

CRM 2013: fn_GetLocalizedLabel in custom CRM SQL Report and LabelTypeCode parameter

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:

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

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
   
}
}

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.

Comments

  1. thank you very much!
    but can you tell me where i can find FormCell objects in database?
    i have localizedlabelview.LabelTypeCode = 8 :)

    ReplyDelete
  2. well, we have found that guids ('unknown' objectIds) in SystemForm.FormXml field
    there's xml markup of entity form, and 'cell id' equals that objectid in LocalizedLabel view





    unfortunately not really easy to work with such xml :(

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. ok.
    got 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)

    ReplyDelete

Post a Comment

Popular posts from this blog

Yet Another Address Autocomplete PCF Control–powered by Bing

In this blog post I will not go into detail in how to install all the pre-requisites that are required to build and run PCF controls. My goal was to build a new PCF control and get into coding of PCF controls as fast as possible. Here are a few links to articles that will help you installing the pre-requisites (Microsoft PowerApps CLI)  https://docs.microsoft.com/en-us/powerapps/developer/component-framework/get-powerapps-cli Other good references to get into this topic: https://toddbaginski.com/blog/how-to-create-a-powerapps-pcf-control/ https://docs.microsoft.com/en-us/powerapps/developer/component-framework/create-custom-controls-using-pcf I looked through the Guido Preite’s https://pcf.gallery/ which will help you find appropriate use cases / examples for your own needs. It did not take very long to find a simple example to start with: Andrew Butenko's https://pcf.gallery/address-autocomplete/ A few moments later I had the idea to create yet another address autocomplete

Regarding SPFieldMultiLineText (Add HTML/URL content to a field) programmatically

I recently tried so set some HTML content in a SharePoint list column of type SPFieldMultiLineText. My first approach was this piece of code: SPFieldMultiLineText field = item.Fields.GetFieldByInternalName( "Associated Documents" ) as SPFieldMultiLineText; StringBuilder docList = new StringBuilder(); docList.Append( " " ); foreach (DataRow docRow in addDocs) { DataRow[] parent = dr.Table.DataSet.Tables[0].Select( "DOK_ID=" + docRow[ "DOK_MGD_ID" ].ToString()); if (parent != null && parent.Length > 0) { docList.AppendFormat( " {1} " , parent[0][ "FilePath" ].ToString(), parent[0][ "Title" ].ToString()); } } if (docList.Length > 0) { // remove trailing tag docList.Remove(docList.Length-5, 5); } docList.Append( " " ); string newValue = docList.ToString(); item[field.Title] = newValue; What this code does is to get all associated documents to the main document and to add these docu

CRM 2016: The attribute with AttributeId = 'guid' was not found in the MetadataCache.

During the export of an unmanged solution I always received the following error message from my CRM 2016 SP1 OnPremise development system: The attribute with AttributeId = '023bda49-9dfa-401e-b348-9374a4141186' was not found in the MetadataCache. Then I tried to remember what I did since the last solution version. => Yes, there was a field that I deleted, because the customer does not need it anymore. Because I am working on-premise it was easy to check the database for the specific attribute. First, I searched in the attribute table: SELECT [AttributeId]   FROM [Dev_MSCRM].[MetadataSchema].[Attribute]   where [AttributeId] = '023bda49-9dfa-401e-b348-9374a4141186' => result was nothing I concluded CRM deleted the field in this table but missed to remove the attribute from our customer solution. Next thing was to check the solutioncomponent table: SELECT [ModifiedOn]       ,[CreatedBy]       ,[ObjectId]       ,[IsMetadata]       ,[ModifiedBy