Is it possible to use the formula string\concatenate to join multi enum and text field values?
concatenate array (enum) and string
Collapse
X
-
Hi,
item, I already considered that, but what would be the values? list(VALUE-1, ... VALUE-N), will I use some Id`s, from where do I achieve them, will I have to use the actual values of all the enum values as string??
The following while condition I don`t understand.
Code:$source = list(0, 1, 2); $target = list(); $i = 0; while($i < array\length($source), $target = array\push( $target, array\at($source, $i) ); $i = $i + 1; );
Comment
-
Using formula requires some programming skills, except when the logic is very simple.
'list' function instantiates an array by given values.
There's no join function at the moment. I suggest adding a custom function. See https://docs.espocrm.com/development...on-in-formula/
custom/Espo/Custom/Core/Formula/Functions/MyGroup/MyJoinType.php
PHP Code:<?php namespace Espo\Custom\Core\Formula\Functions\MyGroup; class MyJoinType extends \Espo\Core\Formula\Functions\Base { public function process(\StdClass $item) { $args = $this->fetchArguments($item); return implode($args[1], $args[0]); } }
`custom/Espo/Custom/Resources/metadata/app/formula.json`
Code:{ "functionClassNameMap": { "my\\join": "Espo\\Custom\\Core\\Formula\\Functions\\MyGroup\\MyJoinType" } }
Code:$joinedString = my\join($array, ', ');
Last edited by yuri; 02-12-2021, 10:17 AM.If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.Comment
-
esforim , yes it has been implemented in 6.1.3 and my formula outputs all values from an enum field this way:
my target field = legendeTechnik, is a plain textfield, that should show all values of an existing enum field named "technik" in one comma separated field.
Formula:
Code:legendeTechnik=array\join(technik, ', ');
technik1, technik2, technik3, ....
Further on you may e.g. concatenate this new text field with other fields as usual.Comment
-
Mr shalmaxb looking at the date wow! 2 and half year later I'm finally playing to your level.
How do you create new lines for each of the technik1, technik2, technik3, .... result?
For example, right now it showing as technik1, technik2, technik3, ....
I want it as
technik1
technik2
technik3, ....Last edited by esforim; 06-29-2023, 09:05 AM.Comment
-
that`s right '\n' for line break. And in case you need to print this in PDF, here is the solution to escape: https://forum.espocrm.com/forum/gene...4187#post94187
-
shalmaxb While we are on this topic, do you ever have to do something like this? I don't know how your technik field data is structured.
Anyone know what Regular Expression type does EspoCRM use? I use regex101.com to test and some regex work and some doesn't. It obviously I'm using the wrong setting so it to be expected. For example: Using this regex in RegEx101 work fine, but if I use it in EspoCRM I don't get a match. Need to know which setting I should be
It because of these array result that I need to separated them into their "category". Currently I'm​ making everyone in the same group so it doesn't work too well, instead of separate them into their group such as "Buyer" and "Seller".
Now it just
technik1
technik2
technik3
Instead of something like
Buyer:
technik ​​
Seller:
technik2
technik3
Do you play regex often?Last edited by esforim; 06-29-2023, 09:18 AM.Comment
-
Comment