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)

Clear option for optionset in business process steps

(0) ShareShare
ReportReport
Posted on by 347

I have a business process flow In one of its steps I have added an option set(sub category)

enter image description here

I am trying to clear the options in the optionset using the below code

Xrm.Page.getControl("new_subcategory").removeOption(100000005)
Xrm.Page.getControl("new_subcategory").clearOptions()

This removes the options for the optionset that is inside the form, but it is not removing for the same option set that is in the step of business process flow

*This post is locked for comments

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

    Hi,

    Find the link : crmadminassist.com/business-rules-crm-2013-clear-field-value

    this might resolve your problem.

    Regards

  • svignesh Profile Picture
    347 on at

    Thanks

    How can I do it when I want to show first four options out of 8 in the option set?

  • Community Member Profile Picture
    on at

    Use JS code to filter out option set based on other option set

    Here is the code

    function optionSetChanged() {

      ///<summary>

      /// Change the dependent picklist values based on the value selected in the control picklist.

      ///</summary>

    var _selectedCasetype = Xrm.Page.getAttribute("new_casetype").getText();

    if(_selectedCasetype != null){

      var _collection = getCollection();

      var _selectedCity = null;

      var _subCaseCat = Xrm.Page.ui.controls.get("new_subcasetype");

      if (_subCaseCat != null)

          _selectedCity = _subCaseCat.getAttribute().getValue();

      var _subCaseOptions = _subCaseCat.getAttribute().getOptions();

      // If Main_Case_Type is empty, then clear the CitIES field.

      if (_selectedCasetype == "") {

          _subCaseCat.clearOptions();

      }

      else {

          for (var i = 0; i < _collection.length; i++) {

              if (_selectedCasetype.toLowerCase() == _collection[i].Main_Case_Type.toLowerCase()) {

                  _subCaseCat.clearOptions();

                  for (var j = 0; j < _collection[i].Sub_Case_Type.length; j++) {

                      for (var k = 0; k < _subCaseOptions.length; k++) {

                          if (_collection[i].Sub_Case_Type[j].toLowerCase() == _subCaseOptions[k].text.toLowerCase()) {

                              _subCaseCat.addOption(_subCaseOptions[k]);

                              break;

                          }

                      }

                  }

                  break;

              }

          }

          if (_subCaseCat != null && _selectedCity != null)

              _subCaseCat.getAttribute().setValue(_selectedCity);

      }

    }

    else{

    alert("Please select an option");

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

    }

    }

    function getCollection() {

      ///<summary>

      /// Creates and returns a collection of Sub_Case_Type with respect to their Countries.

      ///</summary>

      var _collection = new Array();

      var CARDS_SubCat = new Array("CARD ACTIVATION", "CARD LOST", "CHANGE OF FIN", "CHANGE OF PHOTO", "FAULTY", "LOST & FOUND", "NON REC OF CARDS");

      var CARDS_obj = { Main_Case_Type: "CARDS", Sub_Case_Type: CARDS_SubCat };

      _collection.push(CARDS_obj);

      var LINKPOINTS_SubCat = new Array("CHECK LPS BAL", "EXP LPS", "OCBC STMT LPS", "LPs Discrepancy", "Duplicate LPs Crediting", "Duplicate LPs Reversal", "LPs Adjustment", "LPs Reversal", "Multiply redemption", "");

      var LINKPOINTS_obj = { Main_Case_Type: "LINKPOINTS", Sub_Case_Type: LINKPOINTS_SubCat };

      _collection.push(LINKPOINTS_obj);

      var ONLINE_REDEMPTION_SubCat = new Array("PROMOTION", "STARBUY", "KC Campaign", "KE Campaign", "DS Campaign", "Crazy LPs", "LBTC", "Reward Items");

      var ONLINE_REDEMPTION_obj = { Main_Case_Type: "ONLINE REDEMPTION", Sub_Case_Type: ONLINE_REDEMPTION_SubCat };

      _collection.push(ONLINE_REDEMPTION_obj);

    var UPDATE_PARTICULARS_SubCat = new Array("Update Name", "Update Email Address", "Update Mobile No", "Update Residential No", "Update IC/FIN", "Crazy LPs", "Update Address");

      var UPDATE_PARTICULARS_obj = { Main_Case_Type: "UPDATE PARTICULARS", Sub_Case_Type: UPDATE_PARTICULARS_SubCat };

      _collection.push(UPDATE_PARTICULARS_obj);

    var Service_Recovery_SubCat = new Array("Lapse of Service", "Technical Glitch", "Vendor Error", "MED Request", "Deceased Member", "Resigned Member");

      var Service_Recovery_obj = { Main_Case_Type: "Service Recovery", Sub_Case_Type: Service_Recovery_SubCat };

      _collection.push(Service_Recovery_obj);

    var OTHERS_SubCat = new Array("COMPLAINT", "FOODFARE STOREVALUE", "FP REBATES", "OCBC VISA QUERIESt", "RECOGNITION EVENT", "ONLINE SURVEY");

      var OTHERS_obj = { Main_Case_Type: "OTHERS", Sub_Case_Type: OTHERS_SubCat };

      _collection.push(OTHERS_obj);

    var Outbound_Calls_SubCat = new Array("Events", "Promotion");

      var Outbound_Calls_obj = { Main_Case_Type: "Outbound Calls", Sub_Case_Type: Outbound_Calls_SubCat };

      _collection.push(Outbound_Calls_obj);

    var PDPA_SubCat = new Array("Do Not Call", "Do Not SMS", "Do Not Mail", "Do Not Email", "Do Not Fax", "Do Not Send Card", "Unsub All Channels");

      var PDPA_obj = { Main_Case_Type: "PDPA", Sub_Case_Type: PDPA_SubCat };

      _collection.push(PDPA_obj);

    var PDPA_Consent_SubCat = new Array("Call", "SMS", "Mail", "Email", "Fax", "All Channels");

      var PDPA_Consent_obj = { Main_Case_Type: "PDPA Consent", Sub_Case_Type: PDPA_Consent_SubCat };

      _collection.push(PDPA_Consent_obj);

      return _collection;

    }

    Hope it helps !! If so, Mark my answer as Verified !!

    Regards

  • svignesh Profile Picture
    347 on at

    Thanks Nithin

    This works for the form

    But both the clearOptions() and addOption(optionset) are not affecting the steps in the business process flow(refer image)

    did you manage to change them using this code?

  • Community Member Profile Picture
    on at

    Hi Vicky,

    Place both the fields in the form and hide the ....and use JS code on change of option set field this might work for you....

    Regards

  • svignesh Profile Picture
    347 on at

    Yeah Nithin,

    If I have the fields inside the entity form it is working, but it is not changing the field that is added as a step in the business process. Do you think its possible to change that?

  • Community Member Profile Picture
    on at

    This code might work for you

    function populateBetaOptionSet(beta) {

       var xrmPage = Xrm.Page;

       var pickListField = xrmPage.getControl("intip_websiteaccess");

       var options = pickListField.getOptions();

       //save all options  

       if (!window.wsOptions)

       {

            window.wsOptions = {};

            wsOptions.customer = pickListField.getOption(100000000);

            wsOptions.partner = pickListField.getOption(100000001);

            wsOptions.partnerCustomer = pickListField.getOption(100000002);

            wsOptions.customerAndBeta = pickListField.getOption(100000003);

            wsOptions.partnerAndBeta = pickListField.getOption(100000004);

            wsOptions.partnerCustomerAndBeta = pickListField.getOption(100000005);

       }

       //clear all items

       for(var i = 0; i < options.length; i++)

       {

               pickListField.removeOption(options[i].value);          

       }

       if (beta == false) {

           pickListField.addOption(wsOptions.customer);

           pickListField.addOption(wsOptions.partner);

           pickListField.addOption(wsOptions.partnerCustomer);

       }

       pickListField.addOption(wsOptions.customerAndBeta);

       pickListField.addOption(wsOptions.partnerAndBeta);

       pickListField.addOption(wsOptions.partnerCustomerAndBeta);

    }

    Hope it helps !! If so, Mark my answer as Verified !!

    Regards

    Nithin

  • Verified answer
    Hemant Kumar Sahu Profile Picture
    1,829 on at

    Hi Vicky,

    Use this code for fields added under statge

    Xrm.Page.getControl("header_process_" + fieldName).clearOptions();

    below for normal fields present on form:

    Xrm.Page.getControl(fieldName).clearOptions();

    Hope this helps you !

    Thanks

    Hemant

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