cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ahmad-KAISPE
Helper V
Helper V

Disable Field on the basis of Option

Hi all,

 

I have two options "True", "False" in entity form on power apps portal which i have created in cds. I am trying is to disable location field  if i select False in the option.

Ahmad-KAISPE_0-1595227525702.png

Ahmad-KAISPE_1-1595227753800.png

 

I tried to get some help from this thread, unfortunately it throws an error.

 

Can anyone please guide me on this?

Thanks

Regards,

Ahmad 

1 ACCEPTED SOLUTION

Accepted Solutions
hardikv
Impactful Individual
Impactful Individual

Hi @Ahmad-KAISPE 

Please try below code to hide/show Lookup field:

 

$( document ).ready(function() {
	if($("#crf94_options_0").is(":checked")){
		$("#crf94_cliniclocation").closest("td").find("div.control, div.info").hide();
	}else{
		$("#crf94_cliniclocation").closest("td").find("div.control, div.info").show();
	}
	
	$("#decisionmaker_0").change(function(){
        if($("#crf94_options_0").is(":checked")){
            $("#crf94_cliniclocation").closest("td").find("div.control, div.info").hide();
        }else{
            $("#crf94_cliniclocation").closest("td").find("div.control, div.info").show();
        }
    })
	
    $("#crf94_options_1").change(function(){
        if($("#crf94_options_0").is(":checked")){
            $("#crf94_cliniclocation").closest("td").find("div.control, div.info").hide();
        }else{
          $("#crf94_cliniclocation").closest("td").find("div.control, div.info").show();
        }
    })
});

 

View solution in original post

2 REPLIES 2
the365bit
Resolver I
Resolver I

Hi @Ahmad-KAISPE

 

You can do that by adding javascript into your entity form.  The steps below should help you:

 

1. Go to your entity forms and select the one you want to add the custom behavior

 

the365bit_0-1595229880191.png

 

2. Click on Additional Settings and scroll down until "Custom Javascript" and add the statement changing the values for your fields ids

 

 

$(function(){
    $("#your-options-field-id").change(function(){
        // check if selected value is false
        // if it's false set the lookup field as disabled
        if(!$(this).val()){
            $("#your-lookup-field-id").prop( "disabled", true );
        }
    })
})

 

 

 

 

the365bit_1-1595230244318.png

 

3. Clear the portal cache

 

the365bit_0-1595230362666.png

 

Best regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more
hardikv
Impactful Individual
Impactful Individual

Hi @Ahmad-KAISPE 

Please try below code to hide/show Lookup field:

 

$( document ).ready(function() {
	if($("#crf94_options_0").is(":checked")){
		$("#crf94_cliniclocation").closest("td").find("div.control, div.info").hide();
	}else{
		$("#crf94_cliniclocation").closest("td").find("div.control, div.info").show();
	}
	
	$("#decisionmaker_0").change(function(){
        if($("#crf94_options_0").is(":checked")){
            $("#crf94_cliniclocation").closest("td").find("div.control, div.info").hide();
        }else{
            $("#crf94_cliniclocation").closest("td").find("div.control, div.info").show();
        }
    })
	
    $("#crf94_options_1").change(function(){
        if($("#crf94_options_0").is(":checked")){
            $("#crf94_cliniclocation").closest("td").find("div.control, div.info").hide();
        }else{
          $("#crf94_cliniclocation").closest("td").find("div.control, div.info").show();
        }
    })
});

 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,124)