Archive
Case statement in Select clause
Hi,
Below is a sample query that has “CASE statement” in SELECT clause
SELECT EmpID,
CASE
WHEN Salary>=2000 THEN ‘High Salaried’
WHEN Salary<=1000 THEN ‘Medium’
ELSE ‘Below Bar’
END‘New Column’, *
FROM
Employee
Below is the screenshot for reference
Hope it helps 🙂
How to get Object Type Codes of Entities in CRM 2011
Hi,
In this article i have explained different ways to fetch entities “Object Type Code”
- Using SQL Query :-
Query>
SELECT ObjectTypeCode,*
FROM
ENTITYVIEW
Using JScript :-
- The “ObjectTypeCode” can be extracted from Query String using JScript
- “ObjectTypeCode” resides in “etc” query string parameter
- Below is the JScript statement to get “ObjectTypeCode”
var currEntityObjTypeCode= Xrm.Page.context.getQueryStringParameters().etc
Key Points
- Type codes below 10,000 are reserved for OOB entities.
- Custom entities have a value greater than or equal to 10,000.
Note:- Custom entity object type codes may change during import and are not guaranteed to be the same between systems.
Getting Object Type Code by ‘Entity Name’ using Jscript
Below script uses CRM inbuilt logic and return the entity type code (or) object type code for the given entity name.
function getObjectTypeCodeByName(entityName) {
try {
var lookupService = new RemoteCommand(“LookupService”, “RetrieveTypeCode”);
lookupService.SetParameter(“entityName”, entityName);
var result = lookupService.Execute();
if (result.Success && typeof result.ReturnValue == “number”) {
return result.ReturnValue;
} else {
return null;
}
} catch (e) {
alert(“Error while getting ETC by Name – ” + e.description);
}
}
Hope it helps 🙂