Custom Field marked as Show in List

12 views
Skip to first unread message

Mark Orciuch

unread,
Apr 12, 2021, 7:49:23 PMApr 12
to dotCMS User Group
Hello,

I created a custom field called Full Name which is a concatenation of First and Last Name fields. I marked Full Name as Show in List. 

In detail view, the Full Name is shown correctly.

In list view, there is nothing shown in the Full Name column.

Are such computed custom fields not supported in list views? Is there another technique that I could use? Many thanks in advance.

Falzone, Chris

unread,
Apr 13, 2021, 7:28:23 AMApr 13
to dot...@googlegroups.com
I was going to say that I didn't think you could do that with custom fields, but now that I look -- we have some custom fields shown on the listing.  Should work. When you pull the content is the value actually getting set on the contentlet?  Like maybe the edit screen is displaying it based on the logic in the custom field, but isn't actually setting the value back to the field that gets saved to the contentlet.  Like a urlTitle field, sometimes I have a fake "display field" that the user can interact with (or not) but the JS has to actually save that value back to the hidden field because that is what gets saved to the contentlet in the database.  If it doesn't, the logic to display the value still triggers on the edit screen so it appears that the value is set but in reality it is not.

Hope that makes sense.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/230c1b07-6053-4577-bf77-cd5574210a29n%40googlegroups.com.


--

Christopher Falzone

DevOps Engineer

A Q U E N T  /  VITAMIN T

Mark Pitely

unread,
Apr 13, 2021, 9:13:35 AMApr 13
to dot...@googlegroups.com
If you added the custom field *after* the other two were already populated, it won't be set for each entry until you edit them and save them.
As Chris points out, custom field logic is JS logic and isn't run on the database level, only when you edit and save the entry using the backend. If you create the content by CURL/API, it also won't work until edited. At least that is my understanding.

Mark Pitely
Marywood University

Nathan Keiter

unread,
Apr 13, 2021, 10:04:45 AMApr 13
to dot...@googlegroups.com
Yes, custom fields only work on the back-end for manual edits.


If you want something more global you could do it via a Pre-Hook plugin. That would capture any content edits including via API calls.


If you want to update existing records you'll have to do that at the database level manually, then re-index your content type to get the new values into the index and cache.

Nathan I. Keiter | Lead Network Applications Programmer | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Mark Pitely <pit...@maryu.marywood.edu>
Sent: Tuesday, April 13, 2021 9:13 AM
To: dot...@googlegroups.com
Subject: Re: [dotcms] Custom Field marked as Show in List

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
________________________________
If you added the custom field *after* the other two were already populated, it won't be set for each entry until you edit them and save them.
As Chris points out, custom field logic is JS logic and isn't run on the database level, only when you edit and save the entry using the backend. If you create the content by CURL/API, it also won't work until edited. At least that is my understanding.

Mark Pitely
Marywood University

On Tue, Apr 13, 2021 at 7:28 AM 'Falzone, Chris' via dotCMS User Group <dot...@googlegroups.com<mailto:dot...@googlegroups.com>> wrote:
I was going to say that I didn't think you could do that with custom fields, but now that I look -- we have some custom fields shown on the listing. Should work. When you pull the content is the value actually getting set on the contentlet? Like maybe the edit screen is displaying it based on the logic in the custom field, but isn't actually setting the value back to the field that gets saved to the contentlet. Like a urlTitle field, sometimes I have a fake "display field" that the user can interact with (or not) but the JS has to actually save that value back to the hidden field because that is what gets saved to the contentlet in the database. If it doesn't, the logic to display the value still triggers on the edit screen so it appears that the value is set but in reality it is not.

Hope that makes sense.

On Mon, Apr 12, 2021 at 7:49 PM Mark Orciuch <mark_o...@ngsltd.com<mailto:mark_o...@ngsltd.com>> wrote:
Hello,

I created a custom field called Full Name which is a concatenation of First and Last Name fields. I marked Full Name as Show in List.

In detail view, the Full Name is shown correctly.

In list view, there is nothing shown in the Full Name column.

Are such computed custom fields not supported in list views? Is there another technique that I could use? Many thanks in advance.

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,2INDJlPiNjYEqv7mznqsbrG6p2pP6JADUjJoTvKmPz8dHCMED1JQ1wckWxQHOdxXl2dDRIe2C008ygXtKsfQrULVJzwuMOs0yd1zgZh6XL8VaA9clA,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/230c1b07-6053-4577-bf77-cd5574210a29n%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f230c1b07-6053-4577-bf77-cd5574210a29n%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,-HSC-TItSELwWlhX06MBRFPSzgabB6jx-jl5u9W3QLiXGEKMAGEFe1EnDC6ztnYhqTXBN_51FaC_vDmn4PQcAkqXJPGiWU_Vj-ZDHK2lSOlF-WtAyukvuCxC-us,&typo=1>.


--

Christopher Falzone

DevOps Engineer

A Q U E N T / VITAMIN T<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2faquent.com&c=E,1,g44n5BQdtohCS_QczsY3qNCXupiuA7LwyL8NKUugotTP1kzWLWq_Lm2UefX-ssULuhAN5RPDs7YtjFb3MjQKSTULIdBNrNlYnEUWPnG_N_HAZZpd&typo=1>

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,wRmk56X1iXWRxSKrypKlewiRKeMHl-krzhPjY3JrezUt7OAKP2k9GYbCD05W8HM-AkNy3L_MRRq7ryfRgDD4KSL-02G1Q4NIxJXwLDN-3NidzhB9PY5cXbUb&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgVrZpsdhbTMm7sAc0nesDVNQgj4PEoZ78A6ZhthJtF8SQ%40mail.gmail.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2fCAMAbHgVrZpsdhbTMm7sAc0nesDVNQgj4PEoZ78A6ZhthJtF8SQ%2540mail.gmail.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,0VqsiebCOaTmbz8IQXidOfdSPqHoikVgyz8AEts4yeS5i3I1rvbuq0hYITdS8QJYLb76WFYQRZhnuYQil5x6MeCbtcCO4uvuJUiZSSbfJUlWjAnV55fqifM3Vfc,&typo=1>.

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,ios7t-MYC47yOxtGx3gPmGsq2kSo9moay23P6jTTjY8UoJdKvMg1D5RqhWLtk2G3vKOdYmP4z578TRGz5YcZP5_agxRbQFCUTs2m0its_K-4d3bV_Q,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAFeiKqM6odXhgA3kH8qiPiemRFPx46AQQt0-dCf%2B%2BAxNfQxmnA%40mail.gmail.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2fCAFeiKqM6odXhgA3kH8qiPiemRFPx46AQQt0-dCf%252B%252BAxNfQxmnA%2540mail.gmail.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,53LntiYzFnvDg-_3pOzYDs-hRL8SBNmtO5aSha6bWDDgjn96zP-IFMf5N_CRo0T3pCUxL6scGR0tcfvVVUyizwp9iCpiEGTNvK0zh3KkG-SZ_Ec,&typo=1>.

Mark Orciuch

unread,
Apr 13, 2021, 11:19:05 AMApr 13
to dotCMS User Group

Thanks everyone for the great feedback! My custom field is a calculated field (not saved with the contentlet). Are you saying that I need to save it with the contentlet in order to be displayed in the list view? Kind of like with URL Title where the field gets "recalculated" when any of the dependent fields change?

Mark Pitely

unread,
Apr 13, 2021, 11:50:42 AMApr 13
to dot...@googlegroups.com
I'm not sure I really understand the use-case here. If fullname is just concatenating those two proper fields, it probably shouldn't show up in the 'list view', which is a way to access your raw data.
This is not the intended use of custom fields - that is mostly to pull from other data (i.e. build a live list of department names from your department structure, so that you can have a select list for department name on our person entry). Concatenating two fields is a *display* purpose.
You could also always just make a pull on a page:
#foreach ($person in $dotcontent.pull.....)
<hr>
Full Name: $person.firstName $person.lastName
#editContentlet($person.inode)
#end

This would let you list your people in a much nicer/more customizable way than the 'list view' ever will. You could build in search, display pictures, etc. And that 'edit contentlet' will allow the editor with rights to edit it right there.
If you build your content properly, the editor never needs to use the List View of Content. It is there as a convenience to the programmer, in my opinion. It's a great tool, but it is built for searching across contentlets and content types, rather than for displaying the information.

Mark Pitely
Marywood University



Nathan Keiter

unread,
Apr 13, 2021, 12:18:23 PMApr 13
to dot...@googlegroups.com
I am also confused on the purpose of the field. If you are not saving the calculated value anywhere, it can't show up anywhere else. It would just show up on your content edit screen and cease to exist when you close the edit window.


Every custom field has a hidden HTML element associated with it to store a value if you so desire. Setting this value must be done in JavaScript.


In this example I have a select box in my custom field. I then have to manually save the value of the select box into the hidden field that stores a value for the custom field.


groupIds -> this is the Velocity variable for the custom field.


#groupIds_field -> this is the div where dotCMS puts your custom field output. (My select element lives in here.)


#groupIds -> this is the hidden field where the value is saved.


jQuery save code snippet:


/* When new option is selected, copy multi-select value to the hidden field. */
$( "#groupIds_field select" ).change( function() {
$( "#groupIds" ).val( $(this).val() );
});

Nathan I. Keiter | Lead Network Applications Programmer | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Mark Orciuch <mark_o...@ngsltd.com>
Sent: Tuesday, April 13, 2021 11:19 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom Field marked as Show in List

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
________________________________

Thanks everyone for the great feedback! My custom field is a calculated field (not saved with the contentlet). Are you saying that I need to save it with the contentlet in order to be displayed in the list view? Kind of like with URL Title where the field gets "recalculated" when any of the dependent fields change?
On Tuesday, April 13, 2021 at 6:28:23 AM UTC-5 Chris Falzone wrote:
I was going to say that I didn't think you could do that with custom fields, but now that I look -- we have some custom fields shown on the listing. Should work. When you pull the content is the value actually getting set on the contentlet? Like maybe the edit screen is displaying it based on the logic in the custom field, but isn't actually setting the value back to the field that gets saved to the contentlet. Like a urlTitle field, sometimes I have a fake "display field" that the user can interact with (or not) but the JS has to actually save that value back to the hidden field because that is what gets saved to the contentlet in the database. If it doesn't, the logic to display the value still triggers on the edit screen so it appears that the value is set but in reality it is not.

Hope that makes sense.

On Mon, Apr 12, 2021 at 7:49 PM Mark Orciuch <mark_o...@ngsltd.com> wrote:
Hello,

I created a custom field called Full Name which is a concatenation of First and Last Name fields. I marked Full Name as Show in List.

In detail view, the Full Name is shown correctly.

In list view, there is nothing shown in the Full Name column.

Are such computed custom fields not supported in list views? Is there another technique that I could use? Many thanks in advance.

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,3qJYkcTG3e744GFXmQfhHI3LSPooOS5P79g4cIaNAJBn55SmxXmwnNXbJe8fWPrqjjgnAKPTik_pyTFCS4c4lpNxrjvlgouEVPwnEn4HvxQdnL_7IFMhWA,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/230c1b07-6053-4577-bf77-cd5574210a29n%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f230c1b07-6053-4577-bf77-cd5574210a29n%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,kP1hXpJNTUcv-iW470qZYSAEnx3qFJV7wWgGVZhQMMS3Kuih7zLCBiCMLzTUnf5DWWECACdSXArMHYmYnPm_s110Y3uoxFUFTomy-io5&typo=1>.


--

Christopher Falzone

DevOps Engineer

A Q U E N T / VITAMIN T<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2faquent.com&c=E,1,IbVh2driM2u6Tu267oQX7TcSa8hK3olrIjVH-PORTgf5VF8HNgmWisAyvcppLRscS5TJwOybFnyBzqB7zEMdIWBCdP0BrB0AMAdeqqpkJxegMTeax9sisNzZ8A,,&typo=1>

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,JZ0OjFTgkv238bLdnGwkAQaTpsiGIyOzMpMU4n6RzGHy42H7SOStp8HpEtAh8hygkQ2rq9JbyYXDjREQcyQOUMruyd6Gn98zzND6DlP6-jgGLF9DAtC1BNPwyoj1&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/20e6ab01-00b2-4f52-aa29-86f4d2db4d26n%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f20e6ab01-00b2-4f52-aa29-86f4d2db4d26n%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,d_Yq3hMx86x9cE8g7VBeMwame-Dqw5-XlWr9sCegGY7z53HYu3YpG9YvlC-ZAwj_oeUEIIYDTqOrgOJ8T2sNvqYshHOKN12XKevvvCvD_tROWLf0JO_dxp8,&typo=1>.

Mark Orciuch

unread,
Apr 13, 2021, 12:47:41 PMApr 13
to dotCMS User Group
Hi Mark,

The Full Name custom field was a just a small proof of concept to figure out how things work. The ultimate use case is a content type Department Employee related to one Employee and one Department (employee may work for more than one department). In Department Employee content search, I would like to display employee name and department name from the related content. I wanted to see if I can "calculate" these on the fly rather than to "persist" these with each Department Employee (I have hundreds of existing department employees). I hope that this makes sense.

I know that I could create my own custom list view but I am trying to leverage the built-in content search as much as possible. 

Reply all
Reply to author
Forward
0 new messages