diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee
index 3d28d895d..bf65c3ae8 100644
--- a/app/assets/javascripts/app/lib/app_post/utils.coffee
+++ b/app/assets/javascripts/app/lib/app_post/utils.coffee
@@ -464,7 +464,7 @@ class App.Utils
break
if typeof dataRef is 'function'
value = dataRef()
- else if dataRef.toString
+ else if dataRef isnt undefined && dataRef isnt null && dataRef.toString
value = dataRef.toString()
else
value = ''
diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js
index ddff200c7..48b709b69 100644
--- a/public/assets/tests/html_utils.js
+++ b/public/assets/tests/html_utils.js
@@ -898,6 +898,39 @@ test("check replace tags", function() {
verify = App.Utils.replaceTags(message, data)
equal(verify, result)
+ message = "
#{user.firstname} #{not.existing.test}
"
+ result = 'Bob -
'
+ data = {
+ user: {
+ firstname: 'Bob',
+ },
+ }
+ verify = App.Utils.replaceTags(message, data)
+ equal(verify, result)
+
+ message = "#{user.firstname} #{not.existing.test}
"
+ result = 'Bob -
'
+ data = {
+ user: {
+ firstname: 'Bob',
+ not: null,
+ },
+ }
+ verify = App.Utils.replaceTags(message, data)
+ equal(verify, result)
+
+ message = "#{user.firstname} #{not.existing.test}
"
+ result = 'Bob -
'
+ data = {
+ user: {
+ firstname: 'Bob',
+ not: {},
+ },
+ }
+ verify = App.Utils.replaceTags(message, data)
+ equal(verify, result)
+
+
});
// check if last line is a empty line
diff --git a/test/browser/agent_ticket_actions_level0_test.rb b/test/browser/agent_ticket_actions_level0_test.rb
index 16f34b7c2..b7c277dc8 100644
--- a/test/browser/agent_ticket_actions_level0_test.rb
+++ b/test/browser/agent_ticket_actions_level0_test.rb
@@ -140,7 +140,7 @@ class AgentTicketActionLevel0Test < TestCase
watch_for(
browser: browser2,
css: '.active div[data-name=body]',
- value: 'some content ' + random,
+ value: 'some content -' + random,
)
ticket_customer_select(