Posts

Showing posts with the label Power Pages Power Portals Dynamics 365

Power Pages - Make Multi-Select Fields Read only on Power Portals

Image
Hello and welcome to another Javascript post on Power Pages. You can easily find posts on how to set attributes as read-only on Power Pages, but setting a multi-select field as read-only is a little bit challenging. Set Text Field Read Only $("#<attribute name>").attr("readonly", true); Set Multi-Select Read Only $("<div></div>").css({   position: "absolute",   width: "100%",   height: "100%",   top: 0,   left: 0,   background: "" }).appendTo($(".control").css("position", "relative")); By using the code above, you can easily set the multi-select field as read-only this won't hide the selected options.

Power Pages - Multi Select Field Show Hide and Set Business Required Using Javascript

Image
In this Power Portals blog post content, we are going to implement a multi-select field and use JavaScript to hide and show it based on user interactions. Enhance user experience and streamline data entry by revealing the field only when needed.  At the end of this post, you'll be able to hide and show fields based on the option selected in the multi-select field and make it business required as these two options are not available out of the box in power pages. Add the below code in your basic form additional settings. Code: $(document).ready( function () { var field = document.getElementById( 'new_multiselectparentfield' ); $( "#new_multiselectchildfield" ).parent().parent().hide(); // To Hide Multi Select Field var changeField = new MutationObserver( function (mutations) { console.log( 'changed' ); onDisplaySectionChange(); }); changeField.observe(field, { attributes: true , attributeFilter: [ 'value' ] }); MakeRequired( "new_mu...