Zoho Flow - How to consume subarray from webhook
I am trying to integrate my ecommerce cart system with Inventory using Flow by receiving a JSON webhook. Most things are pretty straight forward, however I'm trying to understand how to create a sales order from a transaction that contains multiple items as the items are contained in a subarray. Here is a snippet of the webhook I receive:
- {
- "webhookTrigger": {
- "payload": {
- "_embedded": {
- "fx__customer": {
- "date_created": null,
- "password_hash_config": 8,
- "last_name": "Last",
- "last_login_date": null,
- "tax_id": null,
- "password_salt": null,
- "password_hash_type": "phpass",
- "forgot_password_timestamp": null,
- "date_modified": null,
- "is_anonymous": true,
- "password_hash": "",
- "id": ,
- "first_name": "First",
- "email": "customer@email.com",
- "forgot_password": null
- },
- "fx__payments": [
- {
- "amount": 36.3,
- "cc_exp_month": "01",
- "paypal_payer_id": null,
- "date_created": "2019-06-24T10:26:55-0700",
- "gateway_type": "authorize",
- "third_party_id": null,
- "type": "plastic",
- "cc_number_masked": "xxxxxxxxxxxx1111",
- "cc_exp_year": 2021,
- "cc_type": "Visa",
- "date_modified": "2019-06-24T10:26:55-0700",
- "purchase_order": null,
- "processor_response": "",
- "processor_response_details": null,
- "fraud_protection_score": 0
- }
- ],
- "fx__items": [
- {
- "expires": 0,
- "code": 1863,
- "discount_details": null,
- "is_future_line_item": false,
- "subscription_frequency": null,
- "_embedded": {
- "fx__item_options": [
- {
- "weight_mod": 0,
- "date_modified": null,
- "date_created": null,
- "name": "Color",
- "price_mod": 0,
- "value": "Forest Green"
- }
- ],
- },
- "price": 28.95,
- "delivery_type": "shipped",
- "subscription_start_date": null,
- "discount_name": null,
- "base_price": 28.95,
- "quantity_max": 0,
- "parent_code": null,
- "subscription_next_transaction_date": null,
- "shipto": "Me",
- "height": 0,
- "image": "",
- "quantity": 1,
- "date_created": null,
- "sub_token_url": null,
- "length": 0,
- "weight": 1,
- "discount_type": null,
- "url": "",
- "subscription_end_date": null,
- "date_modified": "2019-06-24T10:23:50-0700",
- "quantity_min": 0,
- "name": "Widget",
- "width": 0,
- "downloadable_url": null
- }
- ],
- "fx__shipments": [
- {
- "country": "US",
- "shipping_service_id": 14,
- "shipping_service_description": "USPS Priority Mail 2-Day",
- "total_price": 36.3,
- "address2": null,
- "city": "Fourtown",
- "address1": "123 Pionener Rd",
- "date_created": "2019-06-24T10:26:55-0700",
- "last_name": "Last",
- "address_name": "Me",
- "total_tax": 0,
- "total_item_price": 28.95,
- "date_modified": "2019-06-24T10:26:55-0700",
- "phone": null,
- "total_shipping": 7.35,
- "company": null,
- "region": "",
- "postal_code": 55555,
- "first_name": "First"
- }
- ],
- "fx__billing_addresses": [
- {
- "customer_postal_code": 55555,
- "customer_country": "US",
- "address2": null,
- "city": "Fourtown",
- "address1": "123 Pionener Rd",
- "date_created": null,
- "customer_phone": null,
- "last_name": "Last",
- "address_name": "Default Billing Address",
- "date_modified": "2019-06-24T10:26:55-0700",
- "company": null,
- "region": "",
- "first_name": "First"
- }
- ]
- },
- "total_shipping": 7.35,
- "total_future_item_price": 0,
- "id": ,
- "is_test": true,
- "transaction_date": "2019-06-24T12:26:55-0500",
- "store_id": ,
- "total_future_shipping": 0,
- "currency_symbol": "$",
- "date_created": null,
- "customer_first_name": "First",
- "total_tax": 0,
- "transaction_type": null,
- "locale_code": "en_US",
- "date_modified": "2019-06-24T10:26:55-0700",
- "customer_email": "customer@email.com",
- "data_is_fed": true,
- "status": "approved"
- }
- }
- }
So if I want the customer name I can use ${webhookTrigger.payload._embedded.fx__customer.first_name} to retrieve the first name. No problem there.
If I want to get the name of the first item I need to use ${webhookTrigger.payload._embedded.fx__items[0].name} by specifying the first position in the items array, but this will only ever retrieve the name of the first item. How do I write this so that I can get the item name for "n" items?
Thank you for your help!
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Zoho Orchestly Resources
Zoho Creator Resources
Zoho WorkDrive Resources
Zoho Campaigns Resources
Zoho CRM Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.