Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to enable the java script on bulk edit form in CRM 2016

Posted on by Microsoft Employee

Hi ,

I want to  enable the java script on bulk edit form to disable some fields only when I'm performing the bulk edit.

Is there anyway to do this ?

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to enable the java script on bulk edit form in CRM 2016

    Here is how you can do it with JavaScript.

    function bulkEditFormLogic(bulkeditchk) {
        try {
            console.log("running bulkEditFormLogic:" + JSON.stringify(bulkeditchk));
            console.log("Xrm.Page.ui value is null =" + (Xrm.Page.ui == null));
            if (Xrm.Page.ui == null) {
                bulkeditchk.attemptnumber += 1;
                if (bulkeditchk.attemptnumber <= bulkeditchk.maxattempts)
                {
                    setTimeout(bulkEditFormLogic, 1000, bulkeditchk);
                }
            }
            else {
                var ftype = Xrm.Page.ui.getFormType();
                if (ftype == 6) {
                    console.log("is bulk edit form");
                    //data from the parent form this bulk edit is being run from, these would have values if the bulk edit was being done in the associated grid of a form
                    var entid = this.parent.frames[0].Xrm.Page.data.entity.getId();
                    var entname = this.parent.frames[0].Xrm.Page.data.entity.getEntityName();
                    //put your code here
                }
            }
        }
        catch (err) {
            console.log("Error in bulk edit logic=>" + err.message);
        }
    }
    //we have to run the bulk edit logic outside of a subscription since it doesn't observe subscriptions anymore
    bulkEditFormLogic({ "attemptnumber": 0, "maxattempts": 6 });
    



  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to enable the java script on bulk edit form in CRM 2016

    Hi,

    The simplest way is to make the fields as read-only in your default forms and make it editable via JavaScript on load.  By doing this you can lock the field on bulk edit

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans