Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to identify an entity has quick create form enabled or not by Javascript?

Posted on by 90

I have some code below by which I am opening quick create form for entities if enabled but if not enabled I want to open in new window. I need to identify the entity has enabled quick create form or not on definition and how to do it by Javascript?

var entityFormOptions = {};
entityFormOptions["entityName"] = "contact";
entityFormOptions["useQuickCreateForm"] = true;
// will make it true if quick create form not enabled
entityFormOptions["openInNewWindow"] = false;
// Set default values for the Contact form var formParameters = {}; 
// Open the form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then( function (success) { console.log(success); }, function (error) { console.log(error); });


*This post is locked for comments

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: How to identify an entity has quick create form enabled or not by Javascript?

    Hello,

    You can query the web api for this information. Something like

    https://<yourCrmOrgUrl>/api/data/v9.1/EntityDefinitions(LogicalName='<entityName>')?$select=IsQuickCreateEnabled

    For example on a CRM Online Organization this would look like

    raduc5.api.crm4.dynamics.com/.../EntityDefinitions(LogicalName='account')?$select=IsQuickCreateEnabled

    There in the response you will have the value for this flag

    {

    @odata.context: "raduc5.api.crm4.dynamics.com/.../v9.1$metadata#EntityDefinitions(IsQuickCreateEnabled)/$entity",

    IsQuickCreateEnabled: true,

    MetadataId: "70816501-edb9-4740-a16c-6a5efbc05d84"

    }

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: How to identify an entity has quick create form enabled or not by Javascript?

    Hi

    Please see below as to how you could check if Quick Create is enabled. Please remember to set your entity logical name, highlighted in red.

    function isQuickCreateEnabled(executionContext)
    {
    var formContext = executionContext.getFormContext();
    var globalContext = Xrm.Utility.getGlobalContext();
    var req = new XMLHttpRequest();
    req.open("GET", globalContext.getClientUrl() + "/api/data/v9.1/EntityDefinitions?$select=IsQuickCreateEnabled&$filter=LogicalName eq 'account'", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function () {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 200)
    {
    debugger;

    var results = JSON.parse(this.response);
    if (test.value[0].IsQuickCreateEnabled) {
    Xrm.Utility.alertDialog("Quick Create is Enabled");
    }
    else
    {
    Xrm.Utility.alertDialog("Quick Create is not Enabled");
    }

    } else
    {
    Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send();
    };

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans