英文:
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 = ".../api/v3/requests/";
headers = {"authtoken":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"};
first_shift_starts_at = (zoho.currentdate + ' ' + '08:00:00').toDateTime();
first_shift_ends_at = (zoho.currentdate + ' ' + '16:00:00').toDateTime();
is_first_shift = zoho.currenttime > first_shift_starts_at && zoho.currenttime < first_shift_ends_at;
second_shift_starts_at = (zoho.currentdate + ' ' + '17:00:00').toDateTime();
second_shift_ends_at = (zoho.currentdate + ' ' + '22:00:00').toDateTime();
is_second_shift = zoho.currenttime > second_shift_starts_at && zoho.currenttime < second_shift_ends_at;
third_shift_starts_at = (zoho.currentdate + ' ' + '23:00:00').toDateTime();
third_shift_ends_at = (zoho.currentdate + ' ' + '07:00:00').toDateTime();
is_third_shift = zoho.currenttime > third_shift_starts_at && zoho.currenttime < third_shift_ends_at;
if(is_first_shift=="Result": "success")
{
input_data = {
"list_info": {
"row_count": 250,
"start_index": 1,
"sort_field": "id",
"sort_order": "asc",
"get_total_count": true,
"search_fields": {
"priority.name": "1st Shift",
"status.name": "Open",
"technician": "null"
}
}
};
}
else if (is_second_shift=="Result": "success")
{
input_data = {
"list_info": {
"row_count": 250,
"start_index": 1,
"sort_field": "id",
"sort_order": "asc",
"get_total_count": true,
"search_fields": {
"priority.name": "2nd Shift",
"status.name": "Open",
"technician": "null"
}
}
};
}
else (is_third_shift=="Result": "success")
{
input_data = {
"list_info": {
"row_count": 250,
"start_index": 1,
"sort_field": "id",
"sort_order": "asc",
"get_total_count": true,
"search_fields": {
"priority.name": "2nd Shift",
"status.name": "Open",
"technician": "null"
}
}
};
};
params = {"input_data": input_data};
response = invokeurl
[
url: url
type: POST
parameters: params
headers: headers
];
info response;
emailSubject = "Unassigned Tickets";
emailBody = "These tickets are currently unassgined in the queue" + input_data "please make sure they are taken ASAP!";
sendmail
[
from: <from_address>
to: <to_address>
subject: emailSubject
message: emailBody
]
returnObj = Collection();
returnObj.insert("result":"success");
returnObj.insert("message": "Update Notification Mail sent successfully");
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 = "These tickets are currently unassgined 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 make 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?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论