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.
Solved! Go to Solution.
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
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
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?
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
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:
There was one more line the instructions mentioned I have to write, like this:
But I didn't know what they refer to by data-name? What value should I add here?
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
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.
While I have my field as read-only, I tried this:
$("#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?
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.
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.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.