i want to enable mandatory for particular field (periodfrom and periodto )when i click on AMC check box ?
*This post is locked for comments
Hi Sabih,
You can use Business Rule Script to make field mandatory no other field change.
Thanks,
Shahbaaz
You can use Business Rule or JavaScript to make field mandatory no other field change.
Hi,
you can use business rule to achieve this
community.dynamics.com/.../using-business-rules-to-hide-fields-and-make-them-required-as-needed
You can do this using JavaScript or Business Rule.
On the change event of the checkbox, set the Requirement Level of the two fields to required.
Using JavaScript:
function chkAMC_OnChange()
{
var isChecked = Xrm.Page.getAttribute("new_chkAMC").getValue();
if (isChecked)
Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("required");
Xrm.Page.getAttribute("new_toDate").setRequiredLevel("required");
}
else
Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("none");
Xrm.Page.getAttribute("new_toDate").setRequiredLevel("none");
JavaScript file should be created and uploaded to server as web resource.
Add Web Resource to form, and add the onChange event to the checkbox control and enter the function name where required.
Logic should be similar to above using Business Rules.
Hope this helps.
checkbox of AMC using from option set so how to write javascript code
for all the checkboxes, are they built using html code?
if yes, follow below post
butenko.pro/.../howto-htmljs-webresources
Hi Wei Jie Fun,
yes all the checkbox are built using html
then refer to the link, on that particular checkbox checked, trigger the JS
function myFunction()
if(htmlcheckbox== true)
window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("required");
window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("none");
Take the help of the following code. Hope it helps:
$(document).ready(function() {
$("#chekcboxControlId").change(function() {if(this.checked) {window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("required");}else{window.parent.Xrm.Page.getAttribute("fieldschema").setRequiredLevel("none");}});
});
If my answer helped to resolve your issue, kindly verify it by clicking 'Yes'. It would be helpful to the other community members seeking to resolve a similar issue.
CheersArpithttps://arpitmscrmhunt.blogspot.in
Modified Aric's code , accessing from web resource to form using window.parent.
Just replace the field name and trigger in on change of checkbox which you want.
function chkAMC_OnChange() { var isChecked = Xrm.Page.getAttribute("new_chkAMC").getValue(); if (isChecked) { window.parent.Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("required"); window.parent.Xrm.Page.getAttribute("new_toDate").setRequiredLevel("required"); } else { window.parent.Xrm.Page.getAttribute("new_fromDate").setRequiredLevel("none"); window.parent.Xrm.Page.getAttribute("new_toDate").setRequiredLevel("none"); } }
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
HR-09070029-0 2
ED-30091530-0 1