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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Hide Custom Activities from Related Activities Based on condition field

(0) ShareShare
ReportReport
Posted on by 140

Hey I want to Hide Custom activity entity from New Activity dropdown based on some field condition 

How could achieve this and is there any scripts or plugins that I could use 

 any code functions or blogs would help 

pastedimage1614893711256v1.png

I have the same question (0)
  • Suggested answer
    MehranBre Profile Picture
    732 on at

    hi,

    you can use "Custom Rule" of "EnableRule" in RibbonWorkBench.

    add a JS webresource for check your conditions and call this function in Custom Rule of Button.

    Best Regards.

  • Community member Profile Picture
    on at
    Hey,

    To hide a custom activity entity from the "New Activity" dropdown based on a field condition, you can use JavaScript code and the Xrm object model provided by the Dynamics 365 platform. Here's an example of how you can achieve this:

    // Function to check the field condition and hide the custom activity entity
    function hideCustomActivityEntity() {
      var formContext = Xrm.Page;
      // Replace "custom_activity" with the logical name of your custom activity entity
      var customActivityEntityName = "custom_activity";
      // Replace "field_name" with the name of the field you want to check the condition on
      var fieldName = "field_name";
      // Replace "condition_value" with the value that should trigger hiding the entity
      var conditionValue = "condition_value";
      // Retrieve the field value
      var fieldValue = formContext.getAttribute(fieldName).getValue();
      // Get the "New Activity" dropdown control
      var newActivityDropdown = formContext.ui.controls.get("navActivities");
      // Check the field condition and hide the custom activity entity if the condition is met
      if (fieldValue === conditionValue) {
        for (var i = 0; i < newActivityDropdown.getControl().childNodes.length; i++) {
          var childNode = newActivityDropdown.getControl().childNodes[i];
          if (childNode.getAttribute("name") === customActivityEntityName) {
            childNode.style.display = "none";
            break;
          }
        }
      }
    }
    // Register the function to execute on form load and field change events
    function registerCustomActivityEntityHide() {
      var formContext = Xrm.Page;
      // Replace "field_name" with the name of the field you want to trigger the condition check on
      var fieldName = "field_name";
      // Execute the function on form load
      formContext.data.entity.addOnLoad(hideCustomActivityEntity);
      // Execute the function whenever the field value changes
      formContext.getAttribute(fieldName).addOnChange(hideCustomActivityEntity);
    }
    // Execute the registration function
    registerCustomActivityEntityHide();

    You need to place this code in a web resource and add it to the form where you want to hide the custom activity entity. Replace the placeholders with the appropriate values for your custom activity entity, field, and condition.
     
    Once the code is in place, the custom activity entity will be hidden from the "New Activity" dropdown whenever the specified field meets the condition you defined.
    Note: This solution assumes you're using the legacy web client in Dynamics 365. If you're using the Unified Interface, you may need to modify the code accordingly.
     
    I hope this helps!
     
     

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans