Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Business rule (show\hide fields) is not working

Posted on by Microsoft Employee

Hello, I have a custom entity "Bank requisites". When a user creates it, he must enter a country. If the country is Russia, the field "Not-resident" must set to "No". If another country is set, the field "Not-resident" must be "Yes". This business rule looks like:

_1104350437044B043C044F043D043D044B043904_.png

I create a new record of "Bank requisites" from Account form, where subgrid is placed.

7140._1104350437044B043C044F043D043D044B043904_2.png

The quick create is disabled on entity "Bank requisites", so the system opens main form:

_1104350437044B043C044F043D043D044B043904_3.png

Then I input "Russia" in Country field. I choose it from look-up on another entity "Location".

_1104350437044B043C044F043D043D044B043904_34.png

I wait, that "Non-resident" will change to "No", but this is not happening. 

_1104350437044B043C044F043D043D044B043904_5.png

And only after saving the record, field "Not-resident" sets to "No" as it must.

Please help, why the rule doesn't work?

I checked the scope, the other business-rules, the field is present on form, condition is met, I have published many times the solution, and so on...

What else can I try?

Thanks in advance!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Business rule (show\hide fields) is not working

    Thank you, Wahaj Rashid! Our developer has checked and found a script, whicn was making similar logic, and conflicted with my business rule.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Business rule (show\hide fields) is not working

    Hi,

    As Wahaj Rashid said, there is nothing wrong with the design of the Business rule, you can check it as he said.

    Or you can try to use JavaScript to determine the value of country and set Not-resident to be Yes or No.

    You can create JavaScript code here first:

    pastedimage1627286897407v1.jpeg

    Then you need to add the OnChange event to the country field:

    pastedimage1627286937579v2.jpeg

    You can refer to the following code:

    function disableField(executionContext){
                    var formContext = executionContext.getFormContext();
                    var country = formContext.getAttribute("country").getValue();
                    if(country == "Russia"){
                                    
                    }else{
                                    
                    }
    }
    

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Frank Gong

  • Verified answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: Business rule (show\hide fields) is not working

    Hi,

    Thank you for your query.

    Did you check if you have any other business rules or JavaScript functions conflicting with this rule?

    Visually this rule seems to be fine.

    Also, try the following:

    • Create a Bank requisite form outside the sub-grid.
    • Disable the business rules on this entity (temporarily) and test the behavior.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans