Dynamic CRM 2013 Learning notes (28) Dynamically set field change events, required fields, and visible with JS

Source: Internet
Author: User
Tags gettext

We know that it is very easy to set the Change event for a field through the interface, whether it is required or not. But sometimes we need to dynamically according to certain conditions to set, then there is a need to use JS to dynamically control.

The following describes how to use JS to dynamically set.

The change event of a dynamic set field

Form on Load Event
function onLoad () {
    Init ();
    PageAttr.delivery_from.addOnChange (Deliveryfromchange);
    PageAttr.type.addOnChange (Typechange);
    PageAttr.order_purpose.addOnChange (Orderpurposechange);
    PageAttr.ship_toid.addOnChange (Getshiptoinfo);
    PageAttr.sold_toid.addOnChange (Orderbychange);
}

one of the Init methods and pageattr, page please refer to my blog " Dynamic CRM 2013 Learning notes (23) CRM JS Smart Tips (CRM-related methods, properties, and Page fields), and pre-release debugging "

Addonchange here is the same as in the form page, add Field onchange event, but in JS more flexible

Two, the Dynamic setting field is required to fill or cancel required

Set Required method: Setrequiredlevel (' Required ')

Cancellation Required: Setrequiredlevel (' none ')

var df = PageAttr.delivery_from.getText ();
  if "Others") {
      PageAttr.deliveryfrom_plsspecify.setRequiredLevel (' required ');
  }
  Else {
      PageAttr.deliveryfrom_plsspecify.setRequiredLevel (' none ');
  }

Third, dynamic set field is visible

Set Visible: SetVisible (True)

Setting not visible: setvisible (False)

var op = pageAttr.order_purpose.getText ();
    if "Replacement of Return materials") {
        Page.rma_noid.setVisible (true);
    }
    Else {
        Page.rma_noid.setVisible (false);
    }

But it's important to note that this is not a attribute here, it can only be set on control.

Dynamic CRM 2013 Learning Notes Series Rollup-ongoing updates

Dynamic CRM 2013 Learning notes (28) Dynamically set field change events, required fields, and visible with JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.