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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Disabling & Enabling fields based on the nullability of the other field

(0) ShareShare
ReportReport
Posted on by 240

here is my code but it does nt work i have put it in the onload event of the form

//My Javascript

var new_originalid= crmForm.all.new_originalid;

//Check the existence of the datetime field. It may not be included in a quick create form!
if new_originalid!= null)
{
crmForm.all.name.disabled = true;
crmForm.all.emailaddress1.disabled = true;
crmForm.all.new_inactivedate.disabled = true;
}
else
{
crmForm.all.name.disabled = false;
crmForm.all.emailaddress1.disabled = false;
crmForm.all.new_inactivedate.disabled = false;
}

pls help

Regards

*This post is locked for comments

I have the same question (0)
  • Grzegorz Kalek Profile Picture
    4,210 on at
    Hi, use Disabled attribute ex. crmForm.all.name.Disabled = true; and add ( after if
  • Jeremy Winchell Profile Picture
    1,165 on at

    Try this:

    //This code will execute for the Create & Update versions of the form
     if((crmForm.FormType == 1) || (crmForm.FormType == 2))
    {
          var _val  = crmForm.all.new_originalid.DataValue;
          if((_val != null) && (_val != ""))
          {
                  crmForm.all.name.Disabled = true;
                  crmForm.all.emailaddress1.Disabled = true;
                  crmForm.all.new_ininactivedate.Disabled = true;
            }
    }

    I didn't re-add the part that enabled the fields because OnLoad() the fields will be editable by default.  If our condition isn't met, then there isn't a reason to change the fields to Enabled when they will already be enabled.

    Jeremy

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans