SQL Script para listar los valores y etiquetas asociadas de un atributo de tipo Picklist
Para uno de los casos de soporte que han caído en mis manos he necesitado conocer las etiquetas asociadas a los valores de un atributo de tipo Picklist.
En estos casos lo más rápido es atacar directamente a los datos a través de una consulta de T-SQL.
Aquí os dejo el script que hemos programado.
-- Description: Labels list for a specific Picklist attribute
-- Author: Spanish Microsoft GTSC Dynamics Support Team
-- Date: Mar 2010
-- Version: 1.1
-- @uiLanguageId must be set with the Id of the user interface language (ESN: 3082, ENU: 1033)
-- @aName must be set with the name of the picklist attribute
-- @eName must be set with the name of the entity
DECLARE @orgDB AS varchar(100)
DECLARE @aName AS varchar(100)
DECLARE @eName AS varchar(100)
DECLARE @uiLanguageId AS int
SET @uiLanguageId = 3082 -- Spanish labels
SET @aName = 'participationtypemask' -- for the participationtypemask attribute
SET @eName = 'ActivityParty' -- of the ActivityParty entity
SELECT e.Name EntityName,
a.Name AttributeName,
ll.LanguageId,
apv.Value,
ll.Label,
ll.LocalizedLabelId,
ll.CustomizationLevel,
ll.InProduction
FROM MetadataSchema.AttributePicklistValue apv JOIN
MetadataSchema.attribute a ON apv.AttributeId = a.AttributeId JOIN
MetadataSchema.Entity e ON a.EntityId = e.EntityId JOIN
MetadataSchema.LocalizedLabel ll ON apv.AttributePicklistValueId = ll.ObjectId
WHERE ll.languageId = @uiLanguageId AND
e.Name = @eName AND
a.Name = @aName
ORDER BY ll.LanguageId, apv.Value
Para usarlo debéis modificar las siguientes asignaciones de variables para especificar el identificador de idioma (recordad que el 3082 es el identificador para el idioma español), el nombre del atributo de tipo Picklist y el de la entidad a la que pertenece el atributo.
SET @uiLanguageId = 3082 -- Spanish labels
SET @aName = 'participationtypemask' -- for the participationtypemask attribute
SET @eName = 'ActivityParty' -- of the ActivityParty entity
El resultado de la ejecución es el siguiente:
El script puede ser descargado a traves del siguiente acceso directo:
Intentaremos ir añadiendo aquellos scripts que vayamos usando en nuestro día a día y los marcaremos con la etiqueta SQL Scripts para su rápida localización.
Seguro que este script no os cambia la vida, pero espero que os sea de utilidad.
Por Nacho Peiro Alba