يوضّح هذا الدليل كيفية كتابة سجلّات مخصّصة ورسائل خطأ تساعد في تحديد المشاكل وحلّها في خطوة من خطوات سير العمل يتعذّر تنفيذها في علامة التبويب "النشاط" ضمن "سير العمل".
تسجّل علامة التبويب "النشاط" تلقائيًا اسم الخطوة التي يتم تنفيذها كما هو محدّد في ملف البيان الخاص بها. لمساعدتك في فهم ما حدث أثناء تنفيذ خطوة، عليك أيضًا كتابة سجلّات مخصّصة للخطوة. إذا واجه المستخدمون سلوكًا غير متوقّع أثناء تنفيذ خطوتك، يمكن أن تساعدهم سجلّاتك في فهم ما حدث.
يتضمّن إدخال السجلّ المفيد سمتَين:
- شريحة تحتوي على رابط تشعّبي يؤدي إلى المرجع الذي تم إنشاؤه أو تعديله بواسطة الخطوة. على سبيل المثال، إذا أنشأت خطوتك مستند Google، استخدِم الشريحة للربط بمستند Google الذي تم إنشاؤه.
- رسالة خطأ تفصيلية تصف سبب تعذّر تنفيذ إحدى الخطوات وكيفية حلّ المشكلة
يوضّح نموذج الرمز التالي كيف يمكن للخطوة onExecuteFunction() تسجيل عملية تشغيل ناجحة وخطأ في علامة التبويب "سجلّ النشاط":
برمجة التطبيقات
function onExecuteFunctionCreateDocument(e) {
// true if the document is successfully created, false if something goes wrong.
var successfulRun = createDocument();
// If successful, return an activity log linking to the created document.
if (successfulRun == true) {
return {
"hostAppAction": {
"workflowAction": {
"returnOutputVariablesAction": {
"variableValues": [
{}
],
"log": {
"textFormatElements": [
{
"text": "Created Google Doc"
},
{
"chip": {
"icon": {
"materialIconName": "edit_document"
},
"url": "https://docs.google.com/document/d/{DOCUMENT}",
"label": "{NAMEOFDOCUMENT}"
}
},
{
"text": "Created doc detailing how to improve product."
}
]
},
"trigger_log": {
"textFormatElements": [
{
"text": "Email log "
}
]
}
}
}
}
};
}
// Otherwise, return an activity log containing an error explaining what happened and how to resolve the issue.
else {
return {
"hostAppAction": {
"workflowAction": {
"returnElementErrorAction": {
"errorActionability": "NOT_ACTIONABLE",
"errorRetryability": "NOT_RETRYABLE",
"error_log": {
"textFormatElements": [
{
"text": "Failed to create Google Doc"
},
{
"chip": {
"icon": {
"materialIconName": "document"
},
"label": "{NAMEOFDOCUMENT}"
}
},
{
"text": "Unable to create Google Document because OAuth verification failed. Grant one of these authorization scopes and try again: https://www.googleapis.com/auth/documents, https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/drive.file"
}
]
}
}
}
}
};
}
}