web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to add two java scripts on single form?

(0) ShareShare
ReportReport
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...

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    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

  • Sabahat Zaman Profile Picture
    10 on at

    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?

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

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

    docs.microsoft.com/.../getformtype

  • Suggested answer
    Amit Katariya007 Profile Picture
    10,409 Moderator on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 72 Super User 2026 Season 1

#2
BillurSamdancioglu Profile Picture

BillurSamdancioglu 64 Most Valuable Professional

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans