web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Need access to a field...
Power Pages
Answered

Need access to a field in Contact entity for use in form for another entity

(0) ShareShare
ReportReport
Posted on by 22

I have a custom entity called Projects and it has an administrative section on the form. My plan was to use a field I created on the Contacts object called "Group" to use JavaScript to hide/show the administrative section on my Projects form. The form is opened from an entity list and can be read-only or edited and I have the buttons setup on the entity list for this.

 

My first attempt was to create a hidden input with the "Group" value on the current contact populated using liquid. Then I planned on using custom JavaScript on the form to check that hidden input and hide/show the administrative section properly on the edit form. This doesn't work because the form's JavaScript seems to be encapsulated so that it can only work inside the form and not on the page as a whole. Attempts to retrieve the hidden input by ID result in a null reference with vanilla JavaScript and a length of 0 with JQuery.

 

It would be nice if I could inject liquid into the form, but I can find no way to do that. Is there any other way of sharing this data to the form?

Categories:
I have the same question (0)
  • justinburch Profile Picture
    Microsoft Employee on at

    Hi @QuantumRemedy,

    The path you attempted is correct, just move your hidden input to the Web Template. E.g.

    Page Template: Full Page

    Web Template = Projects Template

    Web Template: Projects Template (this is your choice - add to existing template, copy & alter, or add the input and use "include" tag to make the existing template below it)

     

    {% extends 'Layout 1 Column' %}
    
    {% block main %}
    
     <input type="hidden" id="contact_group" val="{{ user.new_contactgroup | default: 'unknown' }}">
    
     {% if page.entityform %}
    
     {% entityform id:page.entityform.id %}
    
     {% endif %}
    
    {% endblock %}

     

     

    EntityForm "Custom JavaScript"

     

    $(function() {
     var userGroup = $("#contact_group").val();
     // .. show/hide logic ...
    });

     

     

    EDIT: I just realized you might be saying the EntityForm is a modal - if that's the case, you'll need to use window.parent (possibly multiple levels of .parent) to access the content in the page with the list & hidden input. Try adding a debugger line in the Entity Form JS and use the dev console to find the right path

  • Verified answer
    OOlashyn Profile Picture
    3,498 Most Valuable Professional on at

    Hi @QuantumRemedy ,

    If you only have access to javascript of the form you can use liquid directly there and omit of using hidden fields whatsoever. It will look like this:

    $(function() {
     // crete variable directly instead of input
     var userGroup = "{{user.new_contactgroup | default: 'unknown'}}";
     // .. show/hide logic ...
    });

     

  • QuantumRemedy Profile Picture
    22 on at

    Yes, it is a modal form, I should have stated that is the issue! I think your solution might work but as I was trying it, @OOlashyn posted a solution that entails using liquid inline in the JavaScript and it worked right off. This seems to be a more elegant solution but thank you for your answer as I may need to try what you suggested for other purposes inside modal forms in the future.

     

    Thanks!

  • QuantumRemedy Profile Picture
    22 on at

    Thanks @OOlashyn! This was exactly what I needed. I didn't know that liquid worked when put in the custom JavaScript, but I'm not sure why I didn't try it before. This is perfect!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 33 Super User 2026 Season 1

#2
sannavajjala87 Profile Picture

sannavajjala87 32 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 27

Last 30 days Overall leaderboard