Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to know if opened form is quick create form from JavaScript?

Posted on by 10

I used Xrm.Utility.getGlobalContext().getQueryStringParameters().pageType to check form type, but getQueryStringParameters() looks like deprecated. I don't see the needed in formContext.data.attributes. I've seen ways with additional boolean entity field, checking if there is confirm button that is on quick create form or if there is no some field. Are there any other ways that more like using build-in function?

  • Verified answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: How to know if opened form is quick create form from JavaScript?

    Hi,

    you can get this information by performing a retrieve on the systemForm table using the GUID of the current form.

    To get the GUID of the current form, you can use the following code:

    formItem = formContext.ui.formSelector.getCurrentItem();

    formItemId = formItem.getId();

    You can retrieve the form details by using the following code:

    Xrm.WebApi.retrieveRecord('systemform', "f7d3b417-6220-42ac-9aec-228621129f3b", "?$select=type").then(
        function success(result) {
            console.log(result)
            
        },
        function (error) {
            console.log(error.message);
            // handle error conditions
        }
    );
    

    Result: 

    7713.pastedimage1629971471641v1.png

    Good luck !

  • Verified answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: How to know if opened form is quick create form from JavaScript?

    Hi,

    I would suggest two ways.

    1. CRM Function - In our script we can write below code to get formType:

    Code:

    function onLoad(executionContext)

    {

      var contextObj=executionContext.getContext();

     var pageType=contextObj.getQueryStringParameters().pageType

    }

    7840.pastedimage1629957745404v1.png

    This is best way to achieve this.

    2. Add one more parameter in script function and while registering the script pass the formName as:

    function onLoad(executionContext,formType){

    }
    5657.pastedimage1629958095473v2.png

  • Ram Prakash Profile Picture
    Ram Prakash 2,285 on at
    RE: How to know if opened form is quick create form from JavaScript?

    Hello,

    You can use formContext.context.getQueryStringParameters().pageType

    Link for your reference :

    docs.microsoft.com/.../gg334511(v=crm.7)

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to know if opened form is quick create form from JavaScript?

    Hi,

    You can use this code to get it: formContext.context.getQueryStringParameters().pageType .

    Result:

    6765.pastedimage1629946853475v1.png

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans