Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to add two java scripts on single form?

Posted on by 10

I want to add two different web resources file one that contains code for create type form and one that contains js code for update of form...

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,506 Super User 2024 Season 1 on at
    RE: How to add two java scripts on single form?

    Hello Sabahat,

    Yes you are on right path. You can use the "getFormType" API which will provide form type i.e. Create, Update, Read only, etc.

    And as per your requirement you can perform your task of lock and unlock field.

    Basically make this fields as locked by default and Run a JS which will make this fields as Unlocked for Create form Type.

    Please refer below JS which will help you to implement your requirement.

    itsfascinating.com/.../

    learntoinspire.ca/.../

    Thank you,

    Amit Katariya

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: How to add two java scripts on single form?

    Hi,

    Yes, you should use getFirmType to identity the form type and do your logic.

    docs.microsoft.com/.../getformtype

  • Sabahat Zaman Profile Picture
    Sabahat Zaman 10 on at
    RE: How to add two java scripts on single form?

    actually i want to add customized js code for the edit option of form like when i want to edit an attribute for example group code field of a contact it gives an alert that group code field is lock and actually locks the field during editing of already saved contact. While intitially during creation of contact group field was editable and unlocked.

    I'm thinking of using getformType() method to do that. Is this the right track to do this task?

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to add two java scripts on single form?

    Hi Sabahat,

    All client-side code is initiated by events. In model-driven apps, you associate a specific function in a JavaScript library (Script web resource) to be executed when an event occurs. This function is called an event handler. Each event handler specifies a single function within a JavaScript library and any parameters that can be passed to the function.

    Form event handlers for Dynamics 365 Customer Engagement (on-premises) forms can be configured for the following areas in a form:

    Set up event handlers for a form in Dynamics 365 Customer Engagement (on-premises) | Microsoft Docs

    pastedimage1655864430542v3.png

    pastedimage1655864067320v1.pngpastedimage1655864332514v2.png

    Based on your description,you can select events as follows:

    (1)for create type form

    Form OnSave

    (2)for update of form

    Form OnSave or Field OnChange

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans