diff --git a/application/Espo/Core/Formula/Functions/ValueType.php b/application/Espo/Core/Formula/Functions/ValueType.php index 99ec8add30..1e90fd5e7d 100644 --- a/application/Espo/Core/Formula/Functions/ValueType.php +++ b/application/Espo/Core/Formula/Functions/ValueType.php @@ -1,4 +1,4 @@ -value; + $value = $item->value; + + if (is_string($value)) { + $value = str_replace("\\n", "\n", $value); + } + + return $value; } } \ No newline at end of file diff --git a/application/Espo/Core/Formula/Functions/VariableType.php b/application/Espo/Core/Formula/Functions/VariableType.php index f43fe84efb..863781cf67 100644 --- a/application/Espo/Core/Formula/Functions/VariableType.php +++ b/application/Espo/Core/Formula/Functions/VariableType.php @@ -1,4 +1,4 @@ -getVariables(), $name)) { - throw new Error(); + return null; } return $this->getVariables()->$name; diff --git a/tests/unit/Espo/Core/Formula/FormulaTest.php b/tests/unit/Espo/Core/Formula/FormulaTest.php index b39129dea5..a9559cd9a6 100644 --- a/tests/unit/Espo/Core/Formula/FormulaTest.php +++ b/tests/unit/Espo/Core/Formula/FormulaTest.php @@ -926,6 +926,20 @@ class FormulaTest extends \PHPUnit_Framework_TestCase $this->assertTrue($result); } + function testStringNewLine() + { + $item = json_decode(' + { + "type": "value", + "value": "test\\ntest" + } + '); + + $result = $this->formula->process($item, $this->entity); + + $this->assertEquals("test\ntest", $result); + } + function testVariable() { $item = json_decode('