Skip to main content
Solved

Source field showing a a number in emails


shs_tim.hobson
Skilled Expert
Forum|alt.badge.img+6

We have “SOURCE” shown in our notification emails to agents for FYI purposes but the SOURCE field is showing as a number rather than the text as shown below.

 

Is there a way to get SOURCE to show EMAIL instead of 1 as 1 equals EMAIL?

 

 

Best answer by Daniel Söderlund

@shs_tim.hobson 

I should have done some tests before, the placeholder is a number and not string. 

I tested and got this to work. My IF works as well if you remove the ‘ 

{% case ticket.source %} 
{% when 1 %} Source: E-Mail 
{% when 2 %}Source: Portal 
{% when 3 %}Source: Phone 
{% when 4 %}Source: Chat 
{% when 5 %}Source: Feedback Widget 
{% when 6 %}Source: Outbound Email 
{% else %}Source: Unknown Source 
{% endcase %}

 

View original
Did this topic help you find an answer to your question?

20 replies

Roxwell
Contributor
Forum|alt.badge.img+9
  • Contributor
  • 225 replies
  • November 4, 2024

I would use a liquid filter, to update the source number to the name. 

 

 


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
Roxwell wrote:

I would use a liquid filter, to update the source number to the name. 

 

 

How ? 


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
shs_tim.hobson wrote:

We have “SOURCE” shown in our notification emails to agents for FYI purposes but the SOURCE field is showing as a number rather than the text as shown below.

 

Is there a way to get SOURCE to show EMAIL instead of 1 as 1 equals EMAIL?

 

 

I use an expression to do it; if(‘{{source}}’ == ‘1’,’E-Mail’,if(‘{{source}}’ == ‘2’,’portal’,  etc 


Roxwell
Contributor
Forum|alt.badge.img+9
  • Contributor
  • 225 replies
  • November 4, 2024

Depends on where you’re doing it, either an expression and the parse the expression resut, or a liquid filter if it’s an email. 

{% case ticket.source %}
  {% when '1' %}E-Mail
  {% when '2' %}Portal
  {% when '3' %}Phone
  {% when '4' %}Chat
  {% when '5' %}Feedback Widget
  {% when '6' %}Outbound Email
  {% else %}Unknown Source
{% endcase %}
 


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
Roxwell wrote:

Depends on where you’re doing it, either an expression and the parse the expression resut, or a liquid filter if it’s an email. 

{% case ticket.source %}
  {% when '1' %}E-Mail
  {% when '2' %}Portal
  {% when '3' %}Phone
  {% when '4' %}Chat
  {% when '5' %}Feedback Widget
  {% when '6' %}Outbound Email
  {% else %}Unknown Source
{% endcase %}
 

Looks much better using case then expression and nested if statement. 


Roxwell
Contributor
Forum|alt.badge.img+9
  • Contributor
  • 225 replies
  • November 4, 2024
Daniel Söderlund wrote:
Roxwell wrote:

Depends on where you’re doing it, either an expression and the parse the expression resut, or a liquid filter if it’s an email. 

{% case ticket.source %}
  {% when '1' %}E-Mail
  {% when '2' %}Portal
  {% when '3' %}Phone
  {% when '4' %}Chat
  {% when '5' %}Feedback Widget
  {% when '6' %}Outbound Email
  {% else %}Unknown Source
{% endcase %}
 

Looks much better using case then expression and nested if statement. 

It really depends on your usecase, but Freshworks needs to work on expressions and consistency! 


shs_tim.hobson
Skilled Expert
Forum|alt.badge.img+6
  • Author
  • Skilled Expert
  • 36 replies
  • November 4, 2024

Thanks for the replies but i think i might just take this out of the email to the agents, it seems too complex just for this purpose.

 

@Roxwell you’re right, FreshWorks do really need to make this a lot simpler. I’m starting to pick faults with FreshService now after using for around 3 months.


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
shs_tim.hobson wrote:

Thanks for the replies but i think i might just take this out of the email to the agents, it seems too complex just for this purpose.

 

@Roxwell you’re right, FreshWorks do really need to make this a lot simpler. I’m starting to pick faults with FreshService now after using for around 3 months.

More placeholders would be nice. source_id and source_name so you can chose, sometimes you need the number when you do API calls. 


Roxwell
Contributor
Forum|alt.badge.img+9
  • Contributor
  • 225 replies
  • November 5, 2024
shs_tim.hobson wrote:

Thanks for the replies but i think i might just take this out of the email to the agents, it seems too complex just for this purpose.

 

@Roxwell you’re right, FreshWorks do really need to make this a lot simpler. I’m starting to pick faults with FreshService now after using for around 3 months.

It’s not perfect, but you can do alot.  If you just paste the liquide filter I gave you above in the email template it will work. 


shs_tim.hobson
Skilled Expert
Forum|alt.badge.img+6
  • Author
  • Skilled Expert
  • 36 replies
  • November 8, 2024
Roxwell wrote:
shs_tim.hobson wrote:

Thanks for the replies but i think i might just take this out of the email to the agents, it seems too complex just for this purpose.

 

@Roxwell you’re right, FreshWorks do really need to make this a lot simpler. I’m starting to pick faults with FreshService now after using for around 3 months.

It’s not perfect, but you can do alot.  If you just paste the liquide filter I gave you above in the email template it will work. 

I tried this in the body of the email that is sent to the agents:

{% case ticket.source %}{% when '1' %}E-Mail{% when '2' %}Portal{% when '3' %}Phone{% when '4' %}Chat{% when '5' %}Feedback Widget{% when '6' %}Outbound Email {% else %}Unknown Source{% endcase %}

but it gave a blank email. When I took this out of the email template, the body of the email appeared. Must be doing something wrong somewhere.


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
shs_tim.hobson wrote:
Roxwell wrote:
shs_tim.hobson wrote:

Thanks for the replies but i think i might just take this out of the email to the agents, it seems too complex just for this purpose.

 

@Roxwell you’re right, FreshWorks do really need to make this a lot simpler. I’m starting to pick faults with FreshService now after using for around 3 months.

It’s not perfect, but you can do alot.  If you just paste the liquide filter I gave you above in the email template it will work. 

I tried this in the body of the email that is sent to the agents:

{% case ticket.source %}{% when '1' %}E-Mail{% when '2' %}Portal{% when '3' %}Phone{% when '4' %}Chat{% when '5' %}Feedback Widget{% when '6' %}Outbound Email {% else %}Unknown Source{% endcase %}

but it gave a blank email. When I took this out of the email template, the body of the email appeared. Must be doing something wrong somewhere.

Strange that I can’t get it work, if you get formatting into the code it could be wrong. 

I tried this and everything ens up Unknown/else 
The if statement use to work. 

 

source {{ticket.source}}



{% case ticket.source %}

{% when '1' %}E-Mail

{% when '2' %}Portal

{% when '3' %}Phone

{% when '4' %}Chat

{% when '5' %}Feedback Widget

{% when '6' %}Outbound Email

{% else %}Unknown Source

{% endcase %}



{% if ticket.source == '3' %} 

Phone {{ticket.source}} 

{% else %} 

Other {{ticket.source}} 

{% endif %}

 

 

 


shs_tim.hobson
Skilled Expert
Forum|alt.badge.img+6
  • Author
  • Skilled Expert
  • 36 replies
  • November 27, 2024
Roxwell wrote:
Daniel Söderlund wrote:
Roxwell wrote:

Depends on where you’re doing it, either an expression and the parse the expression resut, or a liquid filter if it’s an email. 

{% case ticket.source %}
  {% when '1' %}E-Mail
  {% when '2' %}Portal
  {% when '3' %}Phone
  {% when '4' %}Chat
  {% when '5' %}Feedback Widget
  {% when '6' %}Outbound Email
  {% else %}Unknown Source
{% endcase %}
 

Looks much better using case then expression and nested if statement. 

It really depends on your usecase, but Freshworks needs to work on expressions and consistency! 

@Roxwell Any chance you can show us or explain where this needs to go please as i’ve had this parked for a couple of weeks but would like to try to get this to work.


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14

Example to your OG post. You add the code direct into the notification template. 

 

Details of the ticket

 

Name: {{placeholder for requester name }}

User’s e-mail: {{placeholder for requester e-mail}}

Organisations(s):

Ticket number: {{place holder for ticket number}}

{% case ticket.source %}
  {% when '1' %}Source: E-Mail
  {% when '2' %}Source: Portal
  {% when '3' %}Source: Phone
  {% when '4' %}Source: Chat
  {% when '5' %}Source: Feedback Widget
  {% when '6' %}Source: Outbound Email
  {% else %}Source: Unknown Source
{% endcase %}

or my version (it’s more old style but case is much cleaner and how you should do it if it works. )
 

{% if ticket.source == '1'%}
Source: E-mail
{% elsif ticket.source == '2'%}
Source: Portal
{% elsif ticket.source == '3'%}
Source: Phone
{% elsif ticket.source == '4'%}
Source: Chat
{% elsif ticket.source == '5'%}
Source: Feedback Widget
{% elsif ticket.source == '6'%}
Source: Outbound Email
{% endif %}

Description:{{placeholder for description}}

 

 

 


Roxwell
Contributor
Forum|alt.badge.img+9
  • Contributor
  • 225 replies
  • November 27, 2024

@shs_tim.hobson  - you literally paste it into the template, and it will magically vanish :D 


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
Roxwell wrote:

@shs_tim.hobson  - you literally paste it into the template, and it will magically vanish :D 

Hi, you need this ? 

source {{ticket.source}}

 

 


shs_tim.hobson
Skilled Expert
Forum|alt.badge.img+6
  • Author
  • Skilled Expert
  • 36 replies
  • November 28, 2024

The lookup / statement isn’t working with the {% case ticket.source} and I'm getting “Source: Unknown Source” in the notification emails, yet when I query the ticket with a WebRequest i can see that it shows “source”: 2

 

 

And the other way using the elsif is not working either.

 


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14

@shs_tim.hobson 

I should have done some tests before, the placeholder is a number and not string. 

I tested and got this to work. My IF works as well if you remove the ‘ 

{% case ticket.source %} 
{% when 1 %} Source: E-Mail 
{% when 2 %}Source: Portal 
{% when 3 %}Source: Phone 
{% when 4 %}Source: Chat 
{% when 5 %}Source: Feedback Widget 
{% when 6 %}Source: Outbound Email 
{% else %}Source: Unknown Source 
{% endcase %}

 


iufore
Community Debut
  • Community Debut
  • 1 reply
  • November 30, 2024

Hello
I have same error
how it fix ?


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
iufore wrote:

Hello
I have same error
how it fix ?

Didn’t you get my latest posts solution to work ?


shs_tim.hobson
Skilled Expert
Forum|alt.badge.img+6
  • Author
  • Skilled Expert
  • 36 replies
  • December 2, 2024

@Daniel Söderlund Thanks for the update, your edit to the script works.

 

@iufore, Add the following to a email notification template or to an email template. You can use a Web Request with a GET and the endpoint of “freshservice.com/api/v2/tickets/{{ticket.id_numeric}}” to query the tickets to show you which source number correlates to the source. I have some custom source items which are 1001, 1002, 1004.

#Your text above this line#
{% case ticket.source %} 
{% when 1 %}Source: Email
{% when 2 %}Source: Portal
{% when 3 %}Source: Phone
{% when 4 %}Source: Chat
{% when 1001 %}Source: Called into Office
{% when 1002 %}Source: In Person
{% when 1004 %}Source: Internal IT Task
{% endcase %}
#Your text below this line#

 


Reply