Hi All,
I am a couple weeks old in Model Driven apps using the CDS/Dataverse but learning quickly. I have a "Country" field and a "State/Province" field. I am trying to reset the "Province/State" field if the country field is changed.
I know this should be an "OnChange" event I am just not sure how this works and do not have any JS coding background. Can anyone direct me on how I can do this now and with future fields please?
Hi Mehdi,
This is working great for me thanks. Just one question - Can I add multiple fields? I tried adding multiple fields using comma but doesnt seem to work.
Hi mykedeabreu,
Yes, you need to create your library. Generally, it is better to create one library per entity. Could you share screenshots for each of the steps you described in your last post.A screenshot of the error will help you to solve the problem.
Please note that you should always use the technical fields names when developing your JavaScript code.
I have my "State" field visible set to false if Country is not populated. When I disable this business rule your method works. If I enable the business rule I cannot see the State field at all.
Does it make a difference if the field I am resetting is a lookup field?
I get:
This is my Library Code:
This is my Handler properties:
Hi Mehdi - Thank you for your help on this. I just want to clarify if I did this right as it is giving me an error now on the form.
Hi,
Please refer to the code below:
function resetField(executionContext, fieldName){ var formContext = executionContext.getFormContext(); formContext.getAttribute(fieldName).setValue(null); }
Event Handler:
Handler Properties
Feel free to ask questions about my code. It works without any problem.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,524 Super User 2024 Season 2
Martin Dráb 228,493 Most Valuable Professional
nmaenpaa 101,148