INTERACT FORUM
More => Old Versions => JRiver Media Center 25 for Windows => Topic started by: Mike Foran on May 22, 2019, 08:28:25 pm
-
I've created a custom library field called 'Year (Release)' to distinguish the year an album was actually released, vs. when the music was actually created. I'd like to set it up with an expression that, if the field has no data, would copy the data from the 'Year' field. But if there is data in the field, it would display that instead. Is it possible to do something like this?
EDIT: to clarify, can a field have either an expression OR manually entered data?
-
MC already has a [Date (released)] field. Why not use that? Although it wouldn't allow the functionality you are looking for as it is a standard field, you could set up a tag on import expression to save the value in the [Year] tag to the [Date (released)] field, if the [Date (released)] tag is empty.
But if you really want to use your new [Year (Release)] field, I think you can make it a "calculated data" field and include an expression that tests the [Year (Release)] field itself to see if it is empty, and if so set it to the [Year] field, if not set it to its current value.
I'm just not sure when and how often that gets calculated though. At record creation definitely.
Try it and see.
-
MC already has a [Date (released)] field. Why not use that?
LOL I missed that field so yeah I will move to that.
But if you really want to use your new [Year (Release)] field, I think you can make it a "calculated data" field and include an expression that tests the [Year (Release)] field itself to see if it is empty, and if so set it to the [Year] field, if not set it to its current value.
Yes, exactly, it's the expression itself that I'm having trouble with. I'm not great with the syntax. I can get it to mirror 'Year' if it is empty, but I can't get it to override with manual data. Not sure how to do it.
-
Well I haven't tested if a custom calculated field can be overwritten by direct data entry, but the expression I was thinking of would be along the lines of;
if([Year (Release)]=[], [Year (Release)]=[Year], [Year (Release)])
Reference: https://wiki.jriver.com/index.php/Conditional_Functions#If
But if you switch to using the [Date (released)] field then that is no longer required. A similar expression could be used for tag on import though.
A lot of metadata sources do have a release date for Albums and Singles, though not all of course. You may find that the [Date (released)] field is already populated if you added it to Views, or could be with lookups using tools such as MusicBrainz.
-
What you are looking for is a field that behaves like [Album Artist (auto)] . [Album Artist (auto)] normaly takes the value of [Album Artist].
But if it's empty, it takes the value of [Artist]. The code looks like this:
FirstNotEmpty([Album Artist], [Artist])
So [Album Artist] is your override field and it falls back to [Artist] otherwise.
What you probably want is something like [Date Release (auto)] with a calculated value like:
FirstNotEmpty([Date (released)], [Date])
I hope that helps.
Brian.
-
What you are looking for is a field that behaves like [Album Artist (auto)] .
Thanks Brian. Yes, that's pretty much it. But this requires a third field to do the Auto calculation, correct? So I would need [Artist] [Album Artist] and then [Album Artist (Auto)] to make it work. But [Album Artist (Auto)] would not be able to accept manual input. I'm looking to see if it can be done with two fields. The first would be a standard input, the second would evaluate itself to see if it were empty, and if so copy the data in the first, but if not, to display the manual data.
I don't think it can be done. I get a circular reference. I'm guessing that a field can't both have an expression AND manual data.
-
You can not do this with only two fields. You need 3, as you have observed. In your case, [Date], [Date Released], [Date (auto)] .
You can think of it this way: [Date] is the default date that will end up in [Date (auto]. But if you want to override this, you put your manual value in [Date Released]. Then [Date (auto)] will have the value of [Date Released].
[Date (auto)] is a calculated field.
This should work just fine for you. I'm assuming you are using this for sorting. Just sort using [Date (auto)] and you're all set.
Brian.
-
This is very cool and I had an issue last night that this is perfect for, thanks Brian.
-
Note that MC does actually allow you to manually enter a value into the [Album Artist (Auto)] field, even though it is a calculated field. But it can give strange results, and may only work because it uses a coded function, not an expression, and seems to in fact write any entered value into [Album Artist]. Well, depending on what other fields have data.
That may have some implications for the above discussion though. I haven't tested.
But a new field called perhaps [Release Date] which uses the expression FirstNotEmpty([Date (released)], [Year]) would do what you originally asked about.
Getting the correct metadata into the standard [Date (released)] field would also do it.