Loading...
 

Tikiwiki-devel (mailman list mirror)


String Manipulation in Relational Trackers

Hi Brendan,

Concat function in Match Calc field definitely works, I am using it on
several sites. Here's an example from one of them:

(concat (date (str Y-m-d) grantDate) (str " ") grantPrice)

Here, grantDate is a Date/Time tracker field, so we are parsing it using
the date function and then concatenating the grantPrice which is another
tracker field. We also separate by empty space. This goes directly into
the Calculation param of the field.

Please also make sure Re-calculation event is save, so the field updates
on each item save operation. Otherwise, you will need to rebuild the
index in order to have it recalculated.

Regards,
Victor


On 10/11/2018 06:35 PM, Brendan Ferguson wrote:
> Hi Guys
>
> I would like to create a unique identifier for a tracker item based on content previously filled out and also data contained within linked tracker items (via itemLink or Relations)
>
> I'm having difficulties figuring out how to perform simple string manipulation even within the same tracker. The Mathematical Calculation field says it employs Advanced Rating calculations, but none of the string functions of Advanced Rating seem to work.
>
> Any clues as to how I would create a tracker field with:
>
> textField: GA1
> Language: de
>
> To equal GA1-de?
>
> Or is this something Tiki currently can't handle?
>
> Thanks
>
> Brendan
>
> ___
> TikiWiki-devel mailing list
> TikiWiki-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

posts: 84312 Canada

Victor, thanks for the explanation. I am able to get it to work now. Seems as though I didn't fully (and still don't) get the syntax. So I was creating variables when I wanted strings and vice versa.

Do you know if its possible to reference values from Item Link fields? Like thisField.itemLinkField. I can use thisField to get the int value of the linked reference, but don't see any documentation on retrieving value(s) within the linked fields. My guess is that is not currently implemented, but was hoping you may even know a workaround or something of the sort.

Brendan


> On Oct 12, 2018, at 10:16 AM, Victor Emanouilov <victor@tiki.org> wrote:
>
> Hi Brendan,
>
> Concat function in Match Calc field definitely works, I am using it on several sites. Here's an example from one of them:
>
> (concat (date (str Y-m-d) grantDate) (str " ") grantPrice)
>
> Here, grantDate is a Date/Time tracker field, so we are parsing it using the date function and then concatenating the grantPrice which is another tracker field. We also separate by empty space. This goes directly into the Calculation param of the field.
>
> Please also make sure Re-calculation event is save, so the field updates on each item save operation. Otherwise, you will need to rebuild the index in order to have it recalculated.
>
> Regards,
> Victor
>
>
> On 10/11/2018 06:35 PM, Brendan Ferguson wrote:
>> Hi Guys
>>
>> I would like to create a unique identifier for a tracker item based on content previously filled out and also data contained within linked tracker items (via itemLink or Relations)
>>
>> I'm having difficulties figuring out how to perform simple string manipulation even within the same tracker. The Mathematical Calculation field says it employs Advanced Rating calculations, but none of the string functions of Advanced Rating seem to work.
>>
>> Any clues as to how I would create a tracker field with:
>>
>> textField: GA1
>> Language: de
>>
>> To equal GA1-de?
>>
>> Or is this something Tiki currently can't handle?
>>
>> Thanks
>>
>> Brendan
>>
>> ___
>> TikiWiki-devel mailing list
>> TikiWiki-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
>
>
> ___
> TikiWiki-devel mailing list
> TikiWiki-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

Yes, there is a workaround but rather ugly. We are planning on expanding
the Math calculations to work better with linked fields but until that
happens, let me give you an example how you can include fields from a
linked tracker:

(if (add (for-each (list declinedWithdrawnDateList) (formula (less-than
dwDeclinedWithdrawnDate (str-to-time reportDate)))))
  (date (str Y-m-d) (add (for-each (list declinedWithdrawnDateList)
(formula (concat dwDeclinedWithdrawnDate)))))
  (str )
)

You use for-each, list and formula functions. Here,
declinedWithdrawnDateList is an ItemsList field - it lists fields from
other tracker connected via ItemLink. So, you can basically get any
field from the other tracker in the current tracker using ItemsList
field. Since it is an array, we use for-each and list functions to
iterate and then inside the formula you can use whatever you need on the
remote tracker field - dwDeclinedWithdrawnDate in our example.
dwDeclinedWithdrawnDate is a field in the remote tracker. I have made
this extension in Tiki 18, so you can include any of the fields in the
remote tracker and use it in a formula. You need an ItemsList connection
first.

Also, note that since for-each iterates an array, we use one of the add
or contact functions to aggregate the results into a scalar value.
Otherwise, it will return an array and you will get wrong results.

As I said, it is ugly but working. Hope to get to the revamp part of
this by Tiki 20!

Regards,
Victor

On 10/12/2018 07:44 PM, Brendan Ferguson wrote:
> Victor, thanks for the explanation. I am able to get it to work now. Seems as though I didn't fully (and still don't) get the syntax. So I was creating variables when I wanted strings and vice versa.
>
> Do you know if its possible to reference values from Item Link fields? Like thisField.itemLinkField. I can use thisField to get the int value of the linked reference, but don't see any documentation on retrieving value(s) within the linked fields. My guess is that is not currently implemented, but was hoping you may even know a workaround or something of the sort.
>
> Brendan
>
>
>> On Oct 12, 2018, at 10:16 AM, Victor Emanouilov <victor@tiki.org> wrote:
>>
>> Hi Brendan,
>>
>> Concat function in Match Calc field definitely works, I am using it on several sites. Here's an example from one of them:
>>
>> (concat (date (str Y-m-d) grantDate) (str " ") grantPrice)
>>
>> Here, grantDate is a Date/Time tracker field, so we are parsing it using the date function and then concatenating the grantPrice which is another tracker field. We also separate by empty space. This goes directly into the Calculation param of the field.
>>
>> Please also make sure Re-calculation event is save, so the field updates on each item save operation. Otherwise, you will need to rebuild the index in order to have it recalculated.
>>
>> Regards,
>> Victor
>>
>>
>> On 10/11/2018 06:35 PM, Brendan Ferguson wrote:
>>> Hi Guys
>>>
>>> I would like to create a unique identifier for a tracker item based on content previously filled out and also data contained within linked tracker items (via itemLink or Relations)
>>>
>>> I'm having difficulties figuring out how to perform simple string manipulation even within the same tracker. The Mathematical Calculation field says it employs Advanced Rating calculations, but none of the string functions of Advanced Rating seem to work.
>>>
>>> Any clues as to how I would create a tracker field with:
>>>
>>> textField: GA1
>>> Language: de
>>>
>>> To equal GA1-de?
>>>
>>> Or is this something Tiki currently can't handle?
>>>
>>> Thanks
>>>
>>> Brendan
>>>
>>> ___
>>> TikiWiki-devel mailing list
>>> TikiWiki-devel at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>>
>>
>> ___
>> TikiWiki-devel mailing list
>> TikiWiki-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
>
> ___
> TikiWiki-devel mailing list
> TikiWiki-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

posts: 84312 Canada

Wow, thanks, Victor! I'm going to give it a try. This looks like it's exactly what I needed. It does look a little messy, but I can live with that.

Mind if I update the documentation with this? It might help me decode the dreadful algorithms I'm about to write.

Brendan

> On Oct 15, 2018, at 3:04 AM, Victor Emanouilov <victor@tiki.org> wrote:
>
> Yes, there is a workaround but rather ugly. We are planning on expanding the Math calculations to work better with linked fields but until that happens, let me give you an example how you can include fields from a linked tracker:
>
> (if (add (for-each (list declinedWithdrawnDateList) (formula (less-than dwDeclinedWithdrawnDate (str-to-time reportDate)))))
> (date (str Y-m-d) (add (for-each (list declinedWithdrawnDateList) (formula (concat dwDeclinedWithdrawnDate)))))
> (str )
> )
>
> You use for-each, list and formula functions. Here, declinedWithdrawnDateList is an ItemsList field - it lists fields from other tracker connected via ItemLink. So, you can basically get any field from the other tracker in the current tracker using ItemsList field. Since it is an array, we use for-each and list functions to iterate and then inside the formula you can use whatever you need on the remote tracker field - dwDeclinedWithdrawnDate in our example. dwDeclinedWithdrawnDate is a field in the remote tracker. I have made this extension in Tiki 18, so you can include any of the fields in the remote tracker and use it in a formula. You need an ItemsList connection first.
>
> Also, note that since for-each iterates an array, we use one of the add or contact functions to aggregate the results into a scalar value. Otherwise, it will return an array and you will get wrong results.
>
> As I said, it is ugly but working. Hope to get to the revamp part of this by Tiki 20!
>
> Regards,
> Victor
>
>> On 10/12/2018 07:44 PM, Brendan Ferguson wrote:
>> Victor, thanks for the explanation. I am able to get it to work now. Seems as though I didn't fully (and still don't) get the syntax. So I was creating variables when I wanted strings and vice versa.
>>
>> Do you know if its possible to reference values from Item Link fields? Like thisField.itemLinkField. I can use thisField to get the int value of the linked reference, but don't see any documentation on retrieving value(s) within the linked fields. My guess is that is not currently implemented, but was hoping you may even know a workaround or something of the sort.
>>
>> Brendan
>>
>>
>>> On Oct 12, 2018, at 10:16 AM, Victor Emanouilov <victor@tiki.org> wrote:
>>>
>>> Hi Brendan,
>>>
>>> Concat function in Match Calc field definitely works, I am using it on several sites. Here's an example from one of them:
>>>
>>> (concat (date (str Y-m-d) grantDate) (str " ") grantPrice)
>>>
>>> Here, grantDate is a Date/Time tracker field, so we are parsing it using the date function and then concatenating the grantPrice which is another tracker field. We also separate by empty space. This goes directly into the Calculation param of the field.
>>>
>>> Please also make sure Re-calculation event is save, so the field updates on each item save operation. Otherwise, you will need to rebuild the index in order to have it recalculated.
>>>
>>> Regards,
>>> Victor
>>>
>>>
>>>> On 10/11/2018 06:35 PM, Brendan Ferguson wrote:
>>>> Hi Guys
>>>>
>>>> I would like to create a unique identifier for a tracker item based on content previously filled out and also data contained within linked tracker items (via itemLink or Relations)
>>>>
>>>> I'm having difficulties figuring out how to perform simple string manipulation even within the same tracker. The Mathematical Calculation field says it employs Advanced Rating calculations, but none of the string functions of Advanced Rating seem to work.
>>>>
>>>> Any clues as to how I would create a tracker field with:
>>>>
>>>> textField: GA1
>>>> Language: de
>>>>
>>>> To equal GA1-de?
>>>>
>>>> Or is this something Tiki currently can't handle?
>>>>
>>>> Thanks
>>>>
>>>> Brendan
>>>>
>>>> ___
>>>> TikiWiki-devel mailing list
>>>> TikiWiki-devel at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>>>
>>>
>>> ___
>>> TikiWiki-devel mailing list
>>> TikiWiki-devel at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>>
>>
>> ___
>> TikiWiki-devel mailing list
>> TikiWiki-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
>
>
> ___
> TikiWiki-devel mailing list
> TikiWiki-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel


___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

Sure, update the docs! It will help others.


On 10/15/2018 04:01 PM, Dr. Sassafras wrote:
> Wow, thanks, Victor! I'm going to give it a try. This looks like it's exactly what I needed. It does look a little messy, but I can live with that.
>
> Mind if I update the documentation with this? It might help me decode the dreadful algorithms I'm about to write.
>
> Brendan
>
>> On Oct 15, 2018, at 3:04 AM, Victor Emanouilov <victor@tiki.org> wrote:
>>
>> Yes, there is a workaround but rather ugly. We are planning on expanding the Math calculations to work better with linked fields but until that happens, let me give you an example how you can include fields from a linked tracker:
>>
>> (if (add (for-each (list declinedWithdrawnDateList) (formula (less-than dwDeclinedWithdrawnDate (str-to-time reportDate)))))
>> (date (str Y-m-d) (add (for-each (list declinedWithdrawnDateList) (formula (concat dwDeclinedWithdrawnDate)))))
>> (str )
>> )
>>
>> You use for-each, list and formula functions. Here, declinedWithdrawnDateList is an ItemsList field - it lists fields from other tracker connected via ItemLink. So, you can basically get any field from the other tracker in the current tracker using ItemsList field. Since it is an array, we use for-each and list functions to iterate and then inside the formula you can use whatever you need on the remote tracker field - dwDeclinedWithdrawnDate in our example. dwDeclinedWithdrawnDate is a field in the remote tracker. I have made this extension in Tiki 18, so you can include any of the fields in the remote tracker and use it in a formula. You need an ItemsList connection first.
>>
>> Also, note that since for-each iterates an array, we use one of the add or contact functions to aggregate the results into a scalar value. Otherwise, it will return an array and you will get wrong results.
>>
>> As I said, it is ugly but working. Hope to get to the revamp part of this by Tiki 20!
>>
>> Regards,
>> Victor
>>
>>> On 10/12/2018 07:44 PM, Brendan Ferguson wrote:
>>> Victor, thanks for the explanation. I am able to get it to work now. Seems as though I didn't fully (and still don't) get the syntax. So I was creating variables when I wanted strings and vice versa.
>>>
>>> Do you know if its possible to reference values from Item Link fields? Like thisField.itemLinkField. I can use thisField to get the int value of the linked reference, but don't see any documentation on retrieving value(s) within the linked fields. My guess is that is not currently implemented, but was hoping you may even know a workaround or something of the sort.
>>>
>>> Brendan
>>>
>>>
>>>> On Oct 12, 2018, at 10:16 AM, Victor Emanouilov <victor@tiki.org> wrote:
>>>>
>>>> Hi Brendan,
>>>>
>>>> Concat function in Match Calc field definitely works, I am using it on several sites. Here's an example from one of them:
>>>>
>>>> (concat (date (str Y-m-d) grantDate) (str " ") grantPrice)
>>>>
>>>> Here, grantDate is a Date/Time tracker field, so we are parsing it using the date function and then concatenating the grantPrice which is another tracker field. We also separate by empty space. This goes directly into the Calculation param of the field.
>>>>
>>>> Please also make sure Re-calculation event is save, so the field updates on each item save operation. Otherwise, you will need to rebuild the index in order to have it recalculated.
>>>>
>>>> Regards,
>>>> Victor
>>>>
>>>>
>>>>> On 10/11/2018 06:35 PM, Brendan Ferguson wrote:
>>>>> Hi Guys
>>>>>
>>>>> I would like to create a unique identifier for a tracker item based on content previously filled out and also data contained within linked tracker items (via itemLink or Relations)
>>>>>
>>>>> I'm having difficulties figuring out how to perform simple string manipulation even within the same tracker. The Mathematical Calculation field says it employs Advanced Rating calculations, but none of the string functions of Advanced Rating seem to work.
>>>>>
>>>>> Any clues as to how I would create a tracker field with:
>>>>>
>>>>> textField: GA1
>>>>> Language: de
>>>>>
>>>>> To equal GA1-de?
>>>>>
>>>>> Or is this something Tiki currently can't handle?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Brendan
>>>>>
>>>>> ___
>>>>> TikiWiki-devel mailing list
>>>>> TikiWiki-devel at lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>>>>
>>>> ___
>>>> TikiWiki-devel mailing list
>>>> TikiWiki-devel at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>>>
>>> ___
>>> TikiWiki-devel mailing list
>>> TikiWiki-devel at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>>
>>
>> ___
>> TikiWiki-devel mailing list
>> TikiWiki-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
> ___
> TikiWiki-devel mailing list
> TikiWiki-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

posts: 84312 Canada

Can't get it to work.

Tested on Trunk & 18
PHP 7.0 & 7.2

Formula taken from https://doc.tiki.org/Calculations#for-each:

(add
(for-each
(list workAuthor)
(formula (concat authorNumber))))

It keeps returning a result of "0" or "" (depending on how its viewed)

I have tried making the itemList a single value only field, and also a multiple value field. Tried changing the view from dropdown to table. Tried adding the values I want to list into the "Multiple Fields" selector for the itemLink, and also tried single only item links.

I'm not getting an error, but it's not returning values.

Tracker: author
Field: authorNumber - Numeric Field - (Items with values of 4 & 12)

Tracker: work
Field: workAuthor - Item Link Field - pointing at tracker author

I created a fresh 18.x install to make sure it wasn't a regression, and only enabled the features required. On trunk, I tried enabling Advanced Rating feature, no luck.

Any ideas of what I am doing wrong? I can create a show instance (if show is fixed now) if you like.

Brendan

___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

Hi Brendan,

I think you need another field in work tracker:

workAuthorNumber which is ItemsList field based on workAuthor ItemLink
listing the authorNumber field from author tracker. The (list FIELD)
portion of the formula only works with ItemsList fields, not ItemLinks.

HTH,
Victor


On 10/15/2018 09:33 PM, Brendan Ferguson wrote:
> Can't get it to work.
>
> Tested on Trunk & 18
> PHP 7.0 & 7.2
>
> Formula taken from https://doc.tiki.org/Calculations#for-each:
>
> (add
> (for-each
> (list workAuthor)
> (formula (concat authorNumber))))
>
> It keeps returning a result of "0" or "" (depending on how its viewed)
>
> I have tried making the itemList a single value only field, and also a multiple value field. Tried changing the view from dropdown to table. Tried adding the values I want to list into the "Multiple Fields" selector for the itemLink, and also tried single only item links.
>
> I'm not getting an error, but it's not returning values.
>
> Tracker: author
> Field: authorNumber - Numeric Field - (Items with values of 4 & 12)
>
> Tracker: work
> Field: workAuthor - Item Link Field - pointing at tracker author
>
> I created a fresh 18.x install to make sure it wasn't a regression, and only enabled the features required. On trunk, I tried enabling Advanced Rating feature, no luck.
>
> Any ideas of what I am doing wrong? I can create a show instance (if show is fixed now) if you like.
>
> Brendan
>
> ___
> TikiWiki-devel mailing list
> TikiWiki-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

posts: 84312 Canada

Thanks, Victor!

It was me. I was thinking plugin Item Link but really need that plugin List. I've got it working now. So many thanks.

It's a great feature.

I tried updating the docs to help make it more clear but was getting 500 errors on edit. Guessing its part of the dogfooding process. Will revisit the docs when doc.to gets more stable.

Brendan


> On Oct 16, 2018, at 8:25 AM, Victor Emanouilov <victor@tiki.org> wrote:
>
> Hi Brendan,
>
> I think you need another field in work tracker:
>
> workAuthorNumber which is ItemsList field based on workAuthor ItemLink listing the authorNumber field from author tracker. The (list FIELD) portion of the formula only works with ItemsList fields, not ItemLinks.
>
> HTH,
> Victor
>
>
> On 10/15/2018 09:33 PM, Brendan Ferguson wrote:
>> Can't get it to work.
>>
>> Tested on Trunk & 18
>> PHP 7.0 & 7.2
>>
>> Formula taken from https://doc.tiki.org/Calculations#for-each:
>>
>> (add
>> (for-each
>> (list workAuthor)
>> (formula (concat authorNumber))))
>>
>> It keeps returning a result of "0" or "" (depending on how its viewed)
>>
>> I have tried making the itemList a single value only field, and also a multiple value field. Tried changing the view from dropdown to table. Tried adding the values I want to list into the "Multiple Fields" selector for the itemLink, and also tried single only item links.
>>
>> I'm not getting an error, but it's not returning values.
>>
>> Tracker: author
>> Field: authorNumber - Numeric Field - (Items with values of 4 & 12)
>>
>> Tracker: work
>> Field: workAuthor - Item Link Field - pointing at tracker author
>>
>> I created a fresh 18.x install to make sure it wasn't a regression, and only enabled the features required. On trunk, I tried enabling Advanced Rating feature, no luck.
>>
>> Any ideas of what I am doing wrong? I can create a show instance (if show is fixed now) if you like.
>>
>> Brendan
>>
>> ___
>> TikiWiki-devel mailing list
>> TikiWiki-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
>
>
> ___
> TikiWiki-devel mailing list
> TikiWiki-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



___
TikiWiki-devel mailing list
TikiWiki-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel


Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.