cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Have a form with read only fields filled dynamically

I want to have a form where I fill the value for some fields in it (for them to be read-only) dynamically. So I want to pass a query string for the department ID, and when I fill a new value for the programmer, I want to add a new entry in the programmer entry with a reference to that department. If I add a new component from the left side and choose form, am not able to do this. Any hint or idea how to do this would be great. I'm still new to PowerApps portals. 

20 REPLIES 20
Highlighted

the way you were adding the entity form should work in my opinion, not sure why it wasn't refreshing, but I am glad it worked via Portal Management App, I personally find it more reliable

 

as you mentioned you already have a relationship between Department and Programmer (1:N), so a department contains a list of programmers, this is usually represented by a sub-grid in your CDS form

the below posts/video show how to add a subgrid to your CDS form, those are old posts and are showing in the classic view, you can use the new modern view or switch to classic when customizing your CDS form

https://www.websan.com/blog/item/714-sub-grids-in-dynamics-365-everything-you-need-in-one-place

https://www.youtube.com/watch?v=WtWP4HuI7xc

 

once you have your subgrid in the form, you need to add an Entity Form Metadata related to the subgrid: https://www.youtube.com/watch?v=8TgpYEaShzo




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

Highlighted

Thanks @OliverRodrigues I'll try it out now. 

Highlighted

Hi @OliverRodrigues I think you misunderstood what I was referring to. The form that I have is to have a new Programmer, I want to have the opposite, I don't want to add a department and then add a list of programmers to it. I want to add a programmer, but I want to show the department as read only because its ID is in the query string. 

 

So I am on a page that says: AddProgrammer?id=[DepartmentID] .. so I want to display the programmer form, but I want to have the department relationship selector showing the department name, but as read-only and submitted when the user clicks submit. Basically what am asking is, can I set the field programmatically based on the ID in the query string and have it as read-only? 

 

 

Highlighted

so you are not coming to the "New Programmer" page via Entity List/Subgrid? it is like a static page with the Department ID in the query string?

 

you can achieve that via JS then, leave the field as read-only and set the value of the field via JS 

https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/262869/setting-value-on-lookup-fie...




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

Highlighted

Didn't work for me, not sure if I did the steps right or not, is there any better/clearer guidance out there to accomplish this? 

This is the code I wrote: 


$("#syst_department").attr("value", "6dc421b4-f9b5-ae22-a812-000c4bab3ffb");
$("#syst_department_entityname").attr("value", "syst_department");

There was one more line the instructions mentioned I have to write, like this: 

$("#syst_department_name").attr("value", $(this).attr("data-name"));

But I didn't know what they refer to by data-name? What value should I add here? 

 

 

Highlighted

please make sure you are reading the solution from the thread

 

the additional one is: $("attribute_name").attr("value","Name"); 

this line of code is used to show something in the lookup field.. you need to pass the department name in the query string as well and populate there

 

your code is probably working fine, but it is not showing anything in the lookup.. as a test you can submit your form and see if it is working




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

Highlighted

I already tried submitting with the 2 lines of code I shared earlier, it didn't work, I could open the dev tools and see the value attribute getting modified in the hidden input fields, but on submitting, it's not doing the lookup between the records. 

 

 

Highlighted

While I have my field as read-only, I tried this: 

$("#syst_department").attr("value", "6dc421b4-f9b5-ae22-a812-000c4bab3ffb");
$("#syst_department_entityname").attr("value", "syst_department");
$("#syst_department_name").attr("value", "Microsoft Division");


No luck. I read through the thread you shared, this is where I got the code from, but for some reason it's not working, or is it different with PowerApps portals? 

 

 

Highlighted

If I leave the field as editable, it will work, but then users will be able to edit the value, if I make it read only from the form settings, it won't work to set it automatically. 

Highlighted

you are better off setting the lookup read-only via JS 

 

$('#<lookup name>').siblings("div.input-group-btn").find("button").prop("disabled", true);
$('#<lookup name>>').siblings("div.input-group-btn").hide();

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Users online (16,063)