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)

How to fire check box on change immedietly?

(0) ShareShare
ReportReport
Posted on by 1,320

How to fire check box on change immedietly?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    suresh p Profile Picture
    1,320 on at

    The following javascript web resource is for fire event when check box clicked or checked in CRM 2011.

    We can get immediate response when CRM check box is Checked or Unchecked.

    Here is the example for Auto Populate Multi-line text field from check box selections.

    Here three check boxes are available. When click on first check box, The text "First option is true" will populate in custom multiline textbox field. As well as click on the second check box, The text "second option is true" will populate in custom multiline textbox field without overwrite data.

    This information has to populate the text box instantly so the user can make changes BEFORE saving the record .

    function CheckOptionOnload()

    {

     RegisterCheckBoxOnclick();

    }

    function RegisterCheckBoxOnclick()

    {

            registerCheckboxClick("new_firstoption");

            registerCheckboxClick("new_secondoption");

            registerCheckboxClick("new_thirdoption");

    }

    function CheckOption()

    {

       var myAttribute1 = "new_firstoption";

       var myControl1 = Xrm.Page.ui.controls.get(myAttribute1);

       var  myCheckboxValue1 = myControl1.getAttribute().getValue();

       var myAttribute2 = "new_secondoption";

       var myControl2 = Xrm.Page.ui.controls.get(myAttribute2);

       var  myCheckboxValue2 = myControl2.getAttribute().getValue();

       var myAttribute3 = "new_thirdoption";

       var myControl3 = Xrm.Page.ui.controls.get(myAttribute3);

       var  myCheckboxValue3 = myControl3.getAttribute().getValue();

      if(myCheckboxValue1 ==false && myCheckboxValue2 ==false && myCheckboxValue3 ==false)

       {

                Xrm.Page.getAttribute("new_description").setValue(null);

       }

      else

       {

          var data="";

          if (myCheckboxValue1 == true)

          {

            data=data+ "First Option is true \n";

            Xrm.Page.getAttribute("new_description").setValue(data);

          }

          if (myCheckboxValue2 == true)

          {

            data=data+ "Second Option is true \n";

           Xrm.Page.getAttribute("new_description").setValue(data);

          }

         if (myCheckboxValue3 == true)

         {

            data=data+ "Third Option is true \n";

            Xrm.Page.getAttribute("new_description").setValue(data);

         }

       }

     }

    function registerCheckboxClick(attr) {

     //var attr="new_firstoption";

      var ctrl = Xrm.Page.ui.controls.get(attr);

       var a = ctrl.getAttribute();

       var el = document.getElementById(attr);

       // Build Toggle Function

       var f = "var ef=function() { " +

                 "var a = Xrm.Page.data.entity.attributes.get(attr); " +

                 "a.setValue(!a.getValue()); a.fireOnChange();" +

                 " };";

       eval(f);

      // Attach to click event

       el.attachEvent('onclick', ef, false);

    }

    Here events and functions are

    Onload : CheckOptionOnload

    Onchange : CheckOption

  • suresh p Profile Picture
    1,320 on at

    function RetrieveFromCCA() {

       orgname = Xrm.Page.context.getOrgUniqueName();

       serverUrl = Xrm.Page.context.getServerUrl();

       var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

       var query = serverUrl + ODATA_ENDPOINT + "/sgs_crmconfigurationsSet?$filter=(sgs_name eq 'CCAURL' or sgs_name eq 'CCAORGNAME')";

        var jSonArray = getDatafromOrg(query);

           var xmlString = "";

            for (var count = 0; count < jSonArray[0].results.length; count++) {

                var Result = jSonArray[0].results.sgs_value;

            }

            }

            function getDatafromOrg(oDataUri) {

           var jSonArray = new Array();

           jQuery.ajax({

           type: "GET",

           contentType: "application/json; charset=utf-8",

           datatype: "json",

           url: oDataUri,

           async: false,

           beforeSend: function (XMLHttpRequest) {

               //Specifying this header ensures that the results will be returned as JSON.            

               XMLHttpRequest.setRequestHeader("Accept", "application/json");

           },

           success: function (data, textStatus, XmlHttpRequest) {

               if (data && data.d != null) {

                   jSonArray.push(data.d);

               }

           },

           error: function (XmlHttpRequest, textStatus, errorThrown) {

               // alert("Error :  has occured during retrieval of the data");

           }

       });

       return jSonArray;

    }

  • Kishore Jaddu Profile Picture
    445 on at

    test

     

  • Kishore Jaddu Profile Picture
    445 on at

    for (var count = 0; count < jSonArray[0].results.length; count++) {

           if (jSonArray[0].results.sgs_name == "CCAURL") {

               var serverURL = jSonArray[0].results[count].sgs_value;

           }

           if (jSonArray[0].results.sgs_name == "CCAORGNAME") {

               var orgName = jSonArray[0].results[count].sgs_value;

           }

       }

       alert(serverURL + "-----" + orgName);

  • Kishore Jaddu Profile Picture
    445 on at
  • suresh p Profile Picture
    1,320 on at

    var Orgname;

    var ServerUrl;

    function UpdateAvailableSlotsInItems() {

    debugger;

       var NewDate = window.parent.Xrm.Page.data.entity.attributes.get("sgs_scheduleddate").getValue();

       if (NewDate != null) {

           yyyy = NewDate.getYear();

           mm = NewDate.getMonth();

           dd = NewDate.getDate();

           var OptionText = window.parent.Xrm.Page.getAttribute("sgs_timezone").getSelectedOption().text;

           var Str = OptionText.substring(4, 10);

           var IsPlus = Str.indexOf("+");

           var IsMinus = Str.indexOf("-");

           if (IsPlus == 0 || IsMinus == 0) {

               Str = Str.replace(":", ".");

               var Oprtr = Str.substring(0, 1);

               Str = Str.substring(1);

               var Split = Str.split('.');

               var hh = parseFloat(Split[0]);

               var mmm = parseFloat(Split[1] / 60)

               var Off = hh + mmm;

               var Offset = Oprtr + Off;

               ConvertedDate = calcTime(Offset, yyyy, mm, dd);

           }

           else {

               var Offset = 0;

               ConvertedDate = calcTime(Offset, yyyy, mm, dd);

           }

           var FromDate = new Date(ConvertedDate)

           if (FromDate.toISOString) {

               FromDate = FromDate.toISOString();

           }

           else {

               FromDate = convertDate(FromDate.toString());

           }

           var ToDate = new Date(ConvertedDate);

           ToDate.setDate(ToDate.getDate() + 1);

           if (ToDate.toISOString) {

               ToDate = ToDate.toISOString();

           }

           else {

               ToDate = convertDate(ToDate.toString());

           }

          Orgname = Xrm.Page.context.getOrgUniqueName();

          ServerUrl = Xrm.Page.context.getServerUrl();

           var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

           var query = ServerUrl + ODATA_ENDPOINT + "/sgs_callbackconfigurationitemSet?$filter=sgs_date gt datetime'" + FromDate + "' and sgs_date le datetime'" + ToDate + "'";

           var jSonArray = getDatafromOrg(query);

           var xmlString = "";

           for (var count = 0; count < jSonArray[0].results.length; count++) {

               var UpdateAvailableItems = jSonArray[0].results[count].sgs_availableslots;

               UpdateAvailableItems -= 1;

           }

       }

    }

    function getDatafromOrg(oDataUri) {

           var jSonArray = new Array();

           jQuery.ajax({

               type: "GET",

               contentType: "application/json; charset=utf-8",

               datatype: "json",

               url: oDataUri,

               async: false,

               beforeSend: function (XMLHttpRequest) {

                   //Specifying this header ensures that the results will be returned as JSON.            

                   XMLHttpRequest.setRequestHeader("Accept", "application/json");

               },

               success: function (data, textStatus, XmlHttpRequest) {

                   if (data && data.d != null) {

                       jSonArray.push(data.d);

                   }

               },

               error: function (XmlHttpRequest, textStatus, errorThrown) {

                   // alert("Error :  has occured during retrieval of the data");

               }

           });

           return jSonArray;

       }

    }

    function calcTime(Offset) {

       var d = new Date(yyyy, mm, dd);

       var utc = d.getTime() + (d.getTimezoneOffset() * 60000);

       var nd = new Date(utc + (3600000 * Offset));

       return nd.toLocaleString();

    }

    if (!Date.prototype.toISOString) {

       Date.prototype.toISOString = function () {

           function pad(n) { return n < 10 ? '0' + n : n }

           return this.getUTCFullYear() + '-'

               + pad(this.getUTCMonth() + 1) + '-'

               + pad(this.getUTCDate()) + 'T'

               + pad(this.getUTCHours()) + ':'

               + pad(this.getUTCMinutes()) + ':'

               + pad(this.getUTCSeconds()) + 'Z';

       };

    }

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