Sunday, May 31, 2020

How to get entity record Url in Dynamic CRM


You can get a Entity Record Url using getUrl()

executionContext.getFormContext().getUrl();


Here is a generalized method to get entity record url based on Classic or UCI type


getEntityRecordUrl: function (executionContext, forceClassic = false, newWindow = true
{   
    var strUIType = 'forceUCI=1';
    if (forceClassic == true || forceClassic == 1)
        strUIType = 'forceClassic=1';

    if (newWindow == 0)
        newWindow = false;

    var entityName = executionContext.getFormContext().data.entity.getEntityName();
    var entityId = executionContext.getFormContext().data.entity.getId().replace('{', '').replace('}', '');

    var entityRecordUrl = executionContext.getContext().getClientUrl() + '/main.aspx?' + strUIType;
    entityRecordUrl += '&newWindow=' + newWindow;
    entityRecordUrl += '&pagetype=entityrecord&etn=' + entityName + '&id=' +  entityId;

    return entityRecordUrl;
}


Refer here to follow best practice while coding in JavaScript

New way to get security role of a Logged-In user, check here

2 comments:

erection pills viagra online said...

Your means of explaining the whole thing in this paragraph is truly pleasant, all be able to simply understand it, Thanks a lot.

erectile said...

These are actually fantastic ideas in about blogging. You have touched some nice points here. Any way keep up wrinting.