يوضح فحص typeof قبل trim وتحويل التاريخ وبوابة IF.
معاينة محتوى الملف مباشرة
{
"name": "M09 - Safe Data Mapping & Expressions",
"nodes": [
{
"parameters": {},
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
220,
300
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"name": "record_id",
"value": "={{ $json.record_id }}",
"type": "string"
},
{
"name": "clean_email",
"value": "={{ typeof $json.contact?.email === \"string\" ? $json.contact.email.trim().toLowerCase() : \"\" }}",
"type": "string"
},
{
"name": "iso_date",
"value": "={{ DateTime.fromFormat(String($json.date ?? \"\"), \"MM/dd/yyyy\").toFormat(\"yyyy-MM-dd\") }}",
"type": "string"
}
]
}
},
"name": "Clean & Format Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
460,
300
]
},
{
"parameters": {
"conditions": {
"conditions": [
{
"leftValue": "={{ $json.clean_email !== \"\" && Boolean($json.record_id) }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "equals"
}
}
]
}
},
"name": "Check Required Email",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
700,
300
]
}
],
"connections": {
"Manual Trigger": {
"main": [
[
{
"node": "Clean & Format Fields",
"type": "main",
"index": 0
}
]
]
},
"Clean & Format Fields": {
"main": [
[
{
"node": "Check Required Email",
"type": "main",
"index": 0
}
]
]
}
}
}