Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

{Portal} Dynamically set a field label using Liquid

(0) ShareShare
ReportReport
Posted on by

I have a unique requirement where I need to dynamically update a Field's label on a portal page.  I know how to grab the dynamic value that I need to append the field label with, but I am not sure how to update a field's label, or if it is possible.  Just looking for some liquid code to adjust the field label on the form.  Example of what I am looking for:

CRM Form field label: Previous Year's Sales

Desired Portal field label: 2018 Year's Sales

I have the ability to get the "2018" text, I just need to inject it into that field's label.

Thanks in advance!

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: {Portal} Dynamically set a field label using Liquid

    Thanks, Aric.

    Because I did not want to display the Year field anywhere on the portal page, I decided to use Liquid code to get the "2018" value.  I then set these values as Javascript variables in a function, and used your code to adjust the field name. It looks something like this (in a Web Template):

    {% assign account= entities.account[request.params.id] %}

    {% if account%}

     {% assign currentyear = account.yearfield.label %}

           {% endif %}

    <script>

    $(document).ready(function () {

     $('#field').text("{{currentyear}} Year Sales");

    });

    </script>

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,188 Moderator on at
    RE: {Portal} Dynamically set a field label using Liquid

    You can use jquery for this. Get the name of the field, and modify the properties as follows:

    var fieldName = "new_yearsales";

    var fieldLabel = "2018 Year's Sales";

    $('#new_yearsales_label').text(fieldLabel);

    Notice that the jQuery field names prepends the # sign, and suffix the _label in order to change the label.

    This code will have to go in your Custom Javascript section of the Entity form:

    $(document).ready(function () {

      $('#new_yearsales_label').text("2018 Year's Sales");

    }

    Hope this helps.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans