web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    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.

  • Community Member Profile Picture
    on at

    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>

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans