如何在Zoho Deluge中将列表导入电子邮件?

huangapple go评论92阅读模式
英文:

How to import a list into an email with Zoho Deluge?

问题

这是您提供的Zoho Deluge脚本。您的问题似乎与将列表信息包含在电子邮件正文中有关。以下是一种可能的方法来创建电子邮件正文:

emailSubject = "Unassigned Tickets";
emailBody = "These tickets are currently unassigned in the queue. Please make sure they are taken ASAP!\n\n";

for each  ticket in response.get("response").get("data")
{
    emailBody = emailBody + "Ticket ID: " + ticket.get("id") + "\n";
    emailBody = emailBody + "Subject: " + ticket.get("subject") + "\n";
    // 继续添加其他您想要包含的信息
    emailBody = emailBody + "\n";
}

sendmail
[
    from: <from_address>
    to:  <to_address>
    subject: emailSubject
    message: emailBody
]

这个代码段将遍历从Zoho Desk获取的响应中的每个票证,并将其信息添加到电子邮件正文中。您可以根据需要添加其他信息。希望这有助于解决您的问题。如果您需要进一步的帮助,请随时提出。

英文:

I was recently tasked with learning the Zoho scripting language Deluge for a project.

That project is essentially to take a list of the tickets that come through Zoho Desk based on priority/shift times and sort them by ones that are unassigned, and then taking that list to send out as an email to inform the team of what needs to be taken.

My issue stems from actually getting the list to be pulled into the email body. When I do the list on its own I'm able to pull the info, and I'm also able to send the emails on their own, but when I end up combining them it always seems to tell me there's an error with the overall script.

Here's the script I have so far:

url = &quot;.../api/v3/requests/&quot;;
headers = {&quot;authtoken&quot;:&quot;XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&quot;};

first_shift_starts_at = (zoho.currentdate + &#39; &#39; + &#39;08:00:00&#39;).toDateTime();
first_shift_ends_at = (zoho.currentdate + &#39; &#39; + &#39;16:00:00&#39;).toDateTime();
is_first_shift = zoho.currenttime &gt; first_shift_starts_at &amp;&amp; zoho.currenttime &lt; first_shift_ends_at;

second_shift_starts_at = (zoho.currentdate + &#39; &#39; + &#39;17:00:00&#39;).toDateTime();
second_shift_ends_at = (zoho.currentdate + &#39; &#39; + &#39;22:00:00&#39;).toDateTime();
is_second_shift = zoho.currenttime &gt; second_shift_starts_at &amp;&amp; zoho.currenttime &lt; second_shift_ends_at;

third_shift_starts_at = (zoho.currentdate + &#39; &#39; + &#39;23:00:00&#39;).toDateTime();
third_shift_ends_at = (zoho.currentdate + &#39; &#39; + &#39;07:00:00&#39;).toDateTime();
is_third_shift = zoho.currenttime &gt; third_shift_starts_at &amp;&amp; zoho.currenttime &lt; third_shift_ends_at;

if(is_first_shift==&quot;Result&quot;: &quot;success&quot;)
{
input_data = {
        &quot;list_info&quot;: {
            &quot;row_count&quot;: 250,
            &quot;start_index&quot;: 1,
            &quot;sort_field&quot;: &quot;id&quot;,
            &quot;sort_order&quot;: &quot;asc&quot;,
            &quot;get_total_count&quot;: true,
            &quot;search_fields&quot;: {
                   		&quot;priority.name&quot;: &quot;1st Shift&quot;,
        			&quot;status.name&quot;: &quot;Open&quot;,
        			&quot;technician&quot;: &quot;null&quot;
        		     }
        	     }
              };
}
else if (is_second_shift==&quot;Result&quot;: &quot;success&quot;)
{
input_data = {
        &quot;list_info&quot;: {
            &quot;row_count&quot;: 250,
            &quot;start_index&quot;: 1,
            &quot;sort_field&quot;: &quot;id&quot;,
            &quot;sort_order&quot;: &quot;asc&quot;,
            &quot;get_total_count&quot;: true,
            &quot;search_fields&quot;: {
                   		&quot;priority.name&quot;: &quot;2nd Shift&quot;,
        			&quot;status.name&quot;: &quot;Open&quot;,
        			&quot;technician&quot;: &quot;null&quot;
        		     }
        	     }
              };
}
else (is_third_shift==&quot;Result&quot;: &quot;success&quot;)
{
input_data = {
        &quot;list_info&quot;: {
            &quot;row_count&quot;: 250,
            &quot;start_index&quot;: 1,
            &quot;sort_field&quot;: &quot;id&quot;,
            &quot;sort_order&quot;: &quot;asc&quot;,
            &quot;get_total_count&quot;: true,
            &quot;search_fields&quot;: {
                   		&quot;priority.name&quot;: &quot;2nd Shift&quot;,
        			&quot;status.name&quot;: &quot;Open&quot;,
        			&quot;technician&quot;: &quot;null&quot;
        		     }
        	     }
              };
};

params = {&quot;input_data&quot;: input_data};
response = invokeurl
[
	url: url
	type: POST 
	parameters: params
	headers: headers
];
info response;

emailSubject = &quot;Unassigned Tickets&quot;;
emailBody = &quot;These tickets are currently unassgined in the queue&quot; + input_data &quot;please make sure they are taken ASAP!&quot;;

sendmail
[
	from: &lt;from_address&gt;
	to:  &lt;to_address&gt;
	subject: emailSubject
	message: emailBody
]


returnObj = Collection();
returnObj.insert(&quot;result&quot;:&quot;success&quot;);
returnObj.insert(&quot;message&quot;: &quot;Update Notification Mail sent successfully&quot;);
return returnObj;	

Any help is very much appreciated!

答案1

得分: 1

This line looks like it is missing a needed + concatenation operator:

emailBody = "These tickets are currently unassigned in the queue" + input_data "please make sure they are taken ASAP!";

Try changing it to (notice the additional + after input_data):

emailBody = "These tickets are currently unassigned in the queue" + input_data + "please make sure they are taken ASAP!";

Also, it might be good to display the contents of emailBody to make sure it is the expected contents before sending it. Add the following after emailBody is assigned:

info emailBody;

05-21-2023 Update:

Notes regarding "Error in if(is_first_shift=="Result": "success")":

Yes, sometimes Zoho-Deluge will report an error that happens on some line within an if block as being an error on the if line.

Re-reading the code, it looks like you made a correct change from
if(is_first_shift=="Result": "success")
to
if(is_first_shift == true)

If you haven't already made that same type of change for the lines:
else if (is_second_shift=="Result": "success")
and
else (is_third_shift=="Result": "success")

That should resolve the error.

05-30-2023 Update:

If the 05-21-2023 Update doesn't resolve the error, then it might be necessary to fall back to some debugging to help identify where the error is occurring. This is because sometimes Zoho-Deluge leans toward being very general in error messages. Try the following and see if they help:

  • Using Deluge's info command, display each of is_first_shift, is_second_shift, and is_third_shift, and make sure they have the values you expect.
    Example code:
    info "is_first_shift: [" + is_first_shift + "]";

  • Try to identify how far the script gets before hitting the error. For example, does the script display the results of info emailBody; or does it fail before then?

英文:

This line looks like it is missing a needed + concatenation operator:

emailBody = &quot;These tickets are currently unassgined in the queue&quot; + input_data &quot;please make sure they are taken ASAP!&quot;;

Try changing it to (notice the additional + after input_data):

emailBody = &quot;These tickets are currently unassigned in the queue&quot; + input_data + &quot;please make sure they are taken ASAP!&quot;;

Also, it might be good to display the contents of emailBody to make sure it is the expected contents before sending it. Add the following after emailBody is assigned:

info emailBody;

05-21-2023 Update:

Notes regarding "Error in if(is_first_shift==&quot;Result&quot;: &quot;success&quot;)":

Yes, sometimes Zoho-Deluge will report an error that happens on some line within an if block as being an error on the if line.

Re-reading the code, it looks like you made a correct change from
if(is_first_shift==&quot;Result&quot;: &quot;success&quot;)
to
if(is_first_shift == true)

If you haven't already make that same type of change for the lines:
else if (is_second_shift==&quot;Result&quot;: &quot;success&quot;)
and
else (is_third_shift==&quot;Result&quot;: &quot;success&quot;)

That should resolve the error.

05-30-2023 Update:

If the 05-21-2023 Update doesn't resolve the error then it might be necessary to fall back to some debugging to help identify where the error is occurring. This is because sometimes Zoho-Deluge leans toward being very general in error messages. Try the following and see if they help:

  • Using Deluge's info command display each of is_first_shift, is_second_shift, and is_third_shift and make sure they have the values you expect.
    Example code:
    info &quot;is_first_shift: [&quot; + is_first_shift + &quot;]&quot;;

  • Try to identify how far the script gets before hitting the error. For example does the script display the results of info emailBody; or does it fail before then?

huangapple
  • 本文由 发表于 2023年5月17日 15:43:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269643.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定