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
Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Users online (4,298)