web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

how to change fields value based on other fields

(0) ShareShare
ReportReport
Posted on by

hello, i have a question.

i have 3 fields that has the same data type = two options.

A = yes / no

B = yes / no

C = yes / no

if i change one of them into "yes" option, the other fields will be automatically "no"

it must be only 1 yes within this 3 fields.

how to change it? 

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Try to do with Business Rules.

    pastedimage1578476380190v1.png

    IF
    Field A equals "Yes"
    THEN
    Set FiedlB to "No"
    Set FieldC to "No"
    ELSE IF
    FiedlB equals "Yes"
    THEN
    Set Field A to "No"
    Set FieldC to "No"
    ELSE IF
    FieldC equals "Yes"
    THEN
    Set Field A to "No"
    Set FiedlB to "No"

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    You could use JS code to do this.

    1.Add this function on the "onchange" event of fieldA.

    function checkValueA(executionContext){
        var formContext=executionContext.getFormContext();
        var valueA=formContext.getAttribute("fieldA").getValue();
        var fieldB=formContext.getAttribute("fieldB");
        var fieldC=formContext.getAttribute("fieldC");
        if(valueA==true){
            fieldB.setValue(false);
            fieldC.setValue(false);
        }
    }

    2.Add this function on the "onchange" event of fieldB.

    function checkValueB(executionContext){
        var formContext=executionContext.getFormContext();
        var valueB=formContext.getAttribute("fieldB").getValue();
        var fieldA=formContext.getAttribute("fieldA");
        var fieldC=formContext.getAttribute("fieldC");
        if(valueB==true){
            fieldA.setValue(false);
            fieldC.setValue(false);
        }
    }

    3.Add this function on the "onchange" event of fieldC.

    function checkValueC(executionContext){
        var formContext=executionContext.getFormContext();
        var valueC=formContext.getAttribute("fieldC").getValue();
        var fieldB=formContext.getAttribute("fieldB");
        var fieldA=formContext.getAttribute("fieldA");
        if(valueC==true){
            fieldB.setValue(false);
            fieldA.setValue(false);
        }
    }

    Hope it helps.

    Best Regards,

    Leo

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I found in my fast answer there is a discrepancy with one business rules , in that case you need to select All NO value and then you have to choose one YES. Its working but you need to click on twice  if there is already a YES value.

    To avoid this you need to create similar logic three different business rules like below  -

    First Business Rules - 

    =================================

    pastedimage1578478320897v1.png

    IF

    Field A equals "Yes"

    THEN
    Set FiedlB to "No"
    Set FieldC to "No"
    Second Business Rule 
    ====================
    IF

    FieldB equals "Yes"

    THEN
    Set FiedlA to "No"
    Set FieldC to "No"
    Third Business Rule
    ===================
    IF

    FieldC equals "Yes"

    THEN
    Set FiedlA to "No"
    Set FieldB to "No"
     
    Doing above is working as expected as per your requirement.
  • Community Member Profile Picture
    on at

    i've tried this and it's work :D

    Thankyou! :)

  • Community Member Profile Picture
    on at

    i've tried this one too, and it's work. thankyou so much! :)

  • gdas Profile Picture
    50,091 Moderator on at

    Have you tried to do my second options creating three business rules (no code approach )?

    If you have not tried then I would suggest try once my second answer, I did my local environment its working . Please don't forget to verify my second answer as this is better approach instead of JavaScript rules , please note  verifying answer will helps other people to choose right and best answer from community forum.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 73 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans