When configuring ribbon elements, you can define specific rules to control when the ribbon elements are enabled. Custom Rule uses the <CustomRule> element. Use this kind of rule to call a function in a Script (JScript) web resource that returns a Promise (Unified Interface) or boolean (Unified Interface and web client). Reference: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/define-ribbon-enable-rules