cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aberson
Frequent Visitor

Hide form fields on entity form on portal

Hello,

I have an entity with lookup fields to customer and contact. I have the contact lookup filtered based on the customer. However if someone chooses contact first they can select any contact.

Is there a way to disable or hide the contact field till a customer is selected?

The end goal is to make sure the contact is associated with the customer selected at form submit.

I have tried business rules but they don’t seem to work on portals..
1 ACCEPTED SOLUTION

Accepted Solutions
sandeepd
Power Apps
Power Apps

@aberson - Form fields are available to you in JavaScript to extend or modify the behavior such as show / hide or enable / disable. See documentation  here provided for web forms but should work for entity forms as well.

Business rules do not work with portal forms.

View solution in original post

5 REPLIES 5
sandeepd
Power Apps
Power Apps

@aberson - Form fields are available to you in JavaScript to extend or modify the behavior such as show / hide or enable / disable. See documentation  here provided for web forms but should work for entity forms as well.

Business rules do not work with portal forms.

v-xida-msft
Community Support
Community Support

Hi @aberson ,

Could you please share a bit more about your scenario?

Do you want to disable or hide the Contact field till the Customer field value is selected?

 

Based on the needs that you mentioned, I think the "Business rules" functionality in CDS Entity could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

6.JPG

 

7.JPG

 

 

8.JPG

More details about creating a Business Rule for a Entity, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/model-driven-apps/create-business-rules-recommendat...

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the response. Either hiding or disabling can work.

I don’t think the business rules work when the CDS form is displayed on a portal.

I tried the java and am unable to select the entire input. I can hide the input by using .parent() and the label separately.

 

However, if i start with the field hidden from the form i can't grab it to show it.... I can't seem to find the logical name of the entity form input to take action on it....

v-xida-msft
Community Support
Community Support

Hi @aberson ,

Have you taken a Custom JavaScript to achieve your needs?

 

Based on the needs that you mentioned, I also agree with @sandeepd 's thought almost. You could consider add a custom JavaScript to the Entity form to control the form field visible or invisible through Power Portal Management.

 

I have made a test on my side, please consider take a try with the following workaround:

1.JPG

Please consider go to your Portal Management (Model-Driven app), then click "Entity forms" tab, then select the Entity form where you want to achieve your logic.

Then switch to "Additional Settings" tab, scroll down to the "Custom JavaScript" part, type the above JavaScript code, then save your Entity form.

$(document).ready(function(){
    var currentValue =  $("#crba2_customer").val();
    if(currentValue==null || currentValue == ''){
        $("#crba2_normalcontact").style.display = 'none'
    }else{
        $("#crba2_normalcontact").style.display = 'block'
    }
})

After that, re-open your Portal, then check if the issue is solved.

 

More details about adding a custom JavaScript in Entity forms/Web Forms, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/add-custom-javascript

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

MPP IDEAS updated 768x460.png

Ideas

Discover ideas and concepts from users like you for how to use Power Pages and take your work to the next level.

Top Solution Authors
Users online (5,074)