Skip to main content

XrmToolBox: AutoNumberUpdater - new StateCode filter

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

Power Automate: Avoid Apply to Each for List rows action (DataVerse)

If you do not want to use the Apply to Each loop after a Dataverse List rows action you can use the following in a Dynamic Content / Expression box to directly use a field's value in e.g. Compose action: first(outputs('List_rows')?['body/value'])?['apx_fullpath'] instead of apx_fullpath you can use whatever field name you need for the entity that's been queried before.

How to add your personal PowerBI Dashboard as a system dashboard

New Approach: Attention: Microsoft added this feature out of the box, so that the manual approach below is not required anymore. More to this can be found here: https://powerapps.microsoft.com/en-us/blog/power-bi-embedded-as-system-dashboard-in-model-driven-apps-preview/ Old Approach: The general guideline on how to create a personal dashboard is described in this article: https://docs.microsoft.com/en-us/powerapps/user/add-powerbi-dashboards But what if you want to rollout a global PowerBI dashboard for all users? With some tweaks you can manage it to make it work… 1. After you have created your personal dashboard you need to extract the formxml of that dashboard with this URL query in a browser tab: https://org.crm4.dynamics.com/api/data/v9.1/userforms?$select=name,formxml&$filter=type eq 103 and name eq 'Ticket Status' Replace… type = 103 => PowerBi Dashboard name = 'Your PowerBI Dashboard Name' In the result copy the XML part out of the "formxm...