EDIT (09/02/17): This post is a result of my exploration into the Xrm.Internal namespace as other internal CRM code in general. It is not a recommendation to use this in a Production environment, as it is UNSUPPORTED. Since there are already ways to run SDK messages from JavaScript using many open source frameworks, I have decided not to post part 2 (how to do this using Xrm.Internal).
Word of warning: Code heavy post and nothing shown here is supported, as it uses internal methods. All these methods have been tested only in Dynamics 365 Online.
Xrm.Internal seems to be a goldmine for cool new functionalities, that one day will eventually make into the Client API. I will document some of the some methods that are useful.
Filter Partylist entity types – Hide unwanted
Scenario: You have opened a new email form. But, you don’t want users to choose contact or lead.
Method Definition: Xrm.Internal.filterLookupTypes([ATTRIBUTE],[ENTITY ARRAY], [FILTER TYPES])
Example
Xrm.Internal.filterLookupTypes(Xrm.Page.getAttribute(“to”), [‘contact’,’lead’], true)
Before
After
Filter Partylist entity types – Show wanted
This is the reverse of the previous scenario. You now want to show only contact and lead. In this case you can use this code.
Xrm.Internal.filterLookupTypes(Xrm.Page.getAttribute(“to”), [‘contact’,’lead’], false)
The order in which the entities appear matter. You can control the resolution order of the entities with this. The first entity on the array is the default selected entity type.
With parameter [‘contact’,’lead’]
With parameter [‘lead’,’contact’]
In both these cases, only the lead and contact entities are shown.
Get entity code from schema name
Method Definition: Xrm.Internal.getEntityCode([ENTITY SCHEMA NAME])
Example
Xrm.Internal.getEntityCode(‘contact’)
Get entity display name from schema name
Method Definition: Xrm.Internal.getEntityDisplayName([ENTITY SCHEMA NAME])
Example
Xrm.Internal.getEntityDisplayName(‘contact’)
Get entity schema name from objecttypecode
Method Definition: Xrm.Internal.getEntityName([ENTITY OBJECT TYPE CODE])
Example
Xrm.Internal.getEntityName(112)
Get state code name from integer value
Method Definition: Xrm.Internal.getStateFromNumber([ENTITY SCHEMA NAME],[STATECODES ARRAY])
getStateFromNumber returns a promise, not a simple value.
Example
Xrm.Internal.getStateFromNumber(‘contact’,[0,1]).done(x=>console.log(x))
Get all features enabled for the current instance
One thing that caught my eye in the feature named “ServeStaticResourcesFromAzureCDN”. I know that learning path assets can be served from Azure CDN. Could this be opened up for other webresources in the future or is this strictly learning path only? I am not sure. Could “ODataV4UI” be Swagger UI or some sort of API Playground? Intriguing.
console.table(Object.keys(Mscrm.FeatureNames).filter(x=>!x.startsWith(‘_’)).map(x=> ({Feature: x, Enabled: Xrm.Internal.isFeatureEnabled(Mscrm.FeatureNames[x])})))
[…] (07/02/2017): Refer Cherry picking Xrm.Internal – Part 1 for an alternate approach using […]
[…] undocumented, unsupported Some methods of […]