Display Rules Using Values from Connected Object's Field

Good Morning…

I’m heading out in a few minutes. My version of KTL is 0.13.15.

Suggestions on getting 0.14.0

Oh! That explains everything.
It’s good news then.

Here’s how you force the KTL to use a specific version:

If you don’t specify the version info (two empty quotes ‘’), it will use the latest official release, which is 0.13.15 in this case. If you write a version, it will switch to it.

The “Full” option simply means that it will use non-minified code. You save on memory usage, and download time, but it’s quite negligible and makes the code much easier to read. Useful when debugging. Not required but will be useful eventually - I’m pretty sure.

ND

You are the man, works as expected.

This is a great feature for me and hopefully others.

Is it “currently” possible to show a field’s value using the _cfv keyword?

Example: if field_380 is “YES” then show field_100’s value?

1 Like

Glad to read that Jon!

I am now working on supporting multiple ktlTarget fields in other view types. So in a couple of days, you will be able to return to the default “” version (blank = latest). I will let you know.

If the hidden state is done in the Builder with a Display rule, then the answer is no. Simply because there’s no way for the KTL to tell Knack to show something.

To do what you want to do, the Builder must always show the field and value, then the KTL can play with its own display rules. Now at the moment, there’s no provision to show something. Only to hide.

To better understand your use case, are you saying that you’d like to use…

_hf=field_100 (to hide by default)

then use something like
_cfv=[field_380, eq, YES, , , , s], [ktlTarget, field_100]

To “unhide” (s for show) field_380 ?

BTW, when I refer to hiding a field, I imply both the field and its value.

Norm

I’d like to have the ability to “hide” a field and it’s value based on the value of a connected field, like you’ve successfully done with the keyword _cfv (e.g. field_380 is “NO” then hide field_100 name and value).

But at the same time, I’d like to be able to “show” a field and it’s value (possibly with different keyword) based on connected field’s value.

Example, if field_380 is “YES” the show field 101’s value.

Same with the action links, if field_380 is “NO” hide action link “testlink1” but if field 380 is “YES” show action link “testlink2”.

Basically I’d like to have the ability to “hide” or “show” fields like the display rules for a details page does but have the ability to reference a connected field like you were able to do with “_cfv”

Hey Norm, the more I mess with this new feature the more I like it and the closer it will resolve me having to rely on Knack’s task systems which is super unreliable and slow.

Couple questions, is there a way of have multiple _cfv strings?

When I apply the following, only the 2nd _cfv rule is working.

_cfv=[field_380, eq, NO, , , ,hp], [ktlTarget, Status]
_cfv=[field_389, eq, OutofOffice, , , s], [ktlTarget, Work Mode Message]

Currently if I hide a field’s label using the label properties in Knack and try to us your new feature, doesn’t work unless I show the label. Is there a way to hide the label and show the field value with your new _cfv feature? Field 389 above is a field that contains a message. I’d like to be able to show the message only and not the label and the message.

Thanks again Norm…

You want to show something, but you don’t say how it was hidden in the first place. You only have two ways to hide a field/value:

  1. In the Builder, using a Display Rule. In this case, you can’t “unhide” that field because the control occurs on the server side. We can only control what’s happening on the client side. If the server doesn’t send you the field/value… how can you show it?! The same as if I’d send you an empty envelope by mail and ask you to read the letter inside.

  2. At runtime, via the KTL or some code+CSS trick like display:none, change transparency to 100%, or move away off screen. In this case, it’s possible to show something that’s been hidden. Either simply re-render the view of remove the style or position that makes it invisible.

ND

Currently no, only the last one will be applied. This is mentioned in the documentation BTW.

See here: Keywords · cortexrd/Knack-Toolkit-Library Wiki (github.com)

“Note: for any keyword used in a field or view, only one instance of each kind can be used. If more than one are included, only the last one will take effect.”

Heard of RTFM? Read The Fantastic Manual !!! :rofl:

But that’s on the works for sure. I knew someone would request this before long!

Norm

Your new feature is giving me the ability to show a field’s value exactly how I want it to with the exception I’d like to be able to keep the field label “hidden” using either with customization from you or using Knack’s display field properties. Having the ability to have multiple _cfv strings would be nice. _csv1, _csv2 ???

Very happy you like it.

About hiding the label of a field, there’s an undocumented keyword that I’ve coded recently that does that.

Try adding this in your details view:

_cls=[ktlHidden], [ktlTarget, .field_1 .kn-detail-label]

Replace field_1 with your field ID.

It adds a class ktlHidden to the jQuery selector “.field_1 .kn-detail-label” which points to the label of that field.

Enjoy,
Norm

I am almost finished coding this capability. It will be ready by tomorrow in several keywords, including _cfv, and _cls.

That will be amazingly powerful!!! :star_struck: :grin: :sunglasses:
Stay tuned.

Norm

Thank again Norm… JON

Jon,

You can give it a try now, with _cfv=… _cfv2=… _cfv3=… etc.

Do Ctrl+F5 to refresh the cache.

Norm

Good Morning Norm, everything you’ve done so far, is working GREAT!!!

Only one thing I’m trying to figure out:

Currently in the page display rules in Knack I have the following “two part” rule:

If field_30 is “N/A” and field_47 is “NO” then show field_100.

Is this currently possible to do with what you done? If so, how?

I know some will ask why not just keep the display rule, but the whole reason for me needing this KTL feature is to get away from using Knack’s very unreliable and slow task management system. Sometimes the tasks are done within 10 minutes, the very next day it takes 2+ hours for the same exact task it did the previous day. With Norm’s KTL system and all that he’s done, I’m that much closer to not using Knack’s task system.

I truly appreciate your time and effort on helping me Norm… JON

Thanks Jon for the nice comments, it’s highly appreciated.

At the moment, the operator in the _cfv keyword is unique, so only one condition is supported. I will eventually try to figure out a way to handle multiple conditional statements, but that will be very complex. It’s not on my short term todo list.

About multiple keywords of same kind in a view/field, I will change that a bit to avoid the numbered keywords. You will only have to use the same plain keyword like this, for example:

_cfv=[group1, …], [group2, …], [ktlRoles, Manager]
_cfv=[group1, …], [group2, …], [ktlRoles, Supervisor]
_cfv=[group1, …], [group2, …], [ktlRoles, President]

No more _cfv2, _cfv3, etc.

So be prepared to change all those you’re currently have using number suffixes, as both formats will not be supported.

Will let you know when the change if done.

BTW…
To keep track of all the keywords you have, go in the console and type ktlkw(). This lists all keywords and their parameters.

You can also use ktlkw(‘_cfv’) to see only this keyword.

Norm

Hi Jon,

I’ve completed the big changes:

  1. All keywords now support ktlRoles
  2. These keywords can now be used multiple times in a view of field:
  • _cfv
  • _cls
  • _hf
  • _hc
  • _rc
  • _style

Again as a reminder, you don’t use the numbers as per initial design, like _cfv2. Just multiple _cfv will work.

These additions now allow you to do all kind of crazy combinations and also apply the keywords on a per-role basis.

Note that the changes in the code were massive. I’d ask you to keep an eye on your console output as much as possible for the next few days, and let me know if you see any errors.

We’re still at 0.14.0, so do a Ctrl+F5 to see the changes.

Chees,
Normand

Thanks Norm, will give changes a try… JON

Hey Norm, I’m trying to hide an action link based on another field’s value in a table view. Can’t seem to get it to work using above suggestions.

Here is what I need: Hide action link “test1” if field value of “field_346” equals “YES”.

Here is what I tried: _cfv =[field_346,is,YES,h], [ktlTarget, #view_233.kn-table-link:contains(“test1”)

When I try the above it hides all of data in the entire table. I’m looking for it to hide just the action link (test1) for that particular record if field_346 = “YES”

Any and all help would be appreciated… JON

Hi Jon,

I see two problems with your string:

_cfv =[field_346,is,YES,h], [ktlTarget, #view_233.kn-table-link:contains(“test1”)

  1. The option is not closed properly. The last square bracket is missing.
  2. The jQuery selector must be in it’s special syntax $(‘selector’)

Try this:

_cfv =[field_346,is,YES,h], [ktlTarget, $('#view_233.kn-table-link:contains(“test1”)')]

Norm

Thank you as always Norm.

Will give it a try… JON