Best answer

Extracting text using REGEX (or other method)


Userlevel 1
Badge

Hi, 
I'm trying to build a Zap that get's a response from an API from Booqable and creates a task in Asana.
I have the response as a value that it's something like this: "4x4 Carbon Fiber Matte Box, Subloc filtro x, subloc bbbb"

And I would like to pass to the next action only strings between commas that have "Subloc" in it (ignoring case). I've tried many things and got some regular expression: (?<=,)[^,]*((?i)Subloc[^,]*)(?=,)*. In every place it returns correctly, but on zapier I got outputs blanks.
I've also tried to "Line-item to text" or "pick from list" inside the format utilities without avail.
Is there a better way to get those two items between commas containing "Subloc" (or "subloc") and pass both (separately) to the next action (create task in asana).
Thank you very much

icon

Best answer by GetUWired 24 May 2022, 15:31

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

11 replies

Userlevel 7
Badge +14

Hi @Lucas Saldanha 

Good question.

Maybe try a bit of code in a Code step.

 

Userlevel 1
Badge

Thank you very much @Troy Tessalone.
What I can't get around my head is that the response is already separate but in the next action only let me select this line with commas (that does not exist on the json response).
The response should (at least when send a get commando for this endpoint in other places) is like this:
 

{
"order": {
"id": "7e35583d-2309-4775-a993-d2277539da2f",
"updated_at": "2022-05-16T15:38:12.526Z",
"created_at": "2022-05-13T22:11:40.194Z",
"properties_attributes": {
"sublocacao": "Sim_Subloc"
},
"price_in_cents": 13500,
"grand_total_in_cents": 0,
"grand_total_with_tax_in_cents": 0,
"tax_in_cents": 0,
"discount_in_cents": 13500,
"coupon_discount_in_cents": 0,
"total_discount_in_cents": 13500,
"deposit_in_cents": 0,
"deposit_paid_in_cents": 0,
"deposit_refunded_in_cents": 0,
"deposit_held_in_cents": 0,
"deposit_to_refund_in_cents": 0,
"to_be_paid_in_cents": 0,
"paid_in_cents": 0,
"number": "9565",
"status": "reserved",
"starts_at": "2022-05-23T20:30:00.000Z",
"stops_at": "2022-05-24T19:15:00.000Z",
"customer_id": "8b64a569-08ff-4075-9ede-be0e63cbf15a",
"discount_percentage": 100.0,
"deposit_type": "none",
"deposit_value": 0.0,
"tags": [],
"tax_region_id": null,
"item_count": 1,
"coupon_id": null,
"tax_strategy": "inclusive",
"currency": "brl",
"shortage": false,
"location_shortage": false,
"payment_status": "Paid",
"start_location_id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"stop_location_id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"statuses": [
"reserved"
],
"status_counts": {
"concept": 0,
"new": 0,
"reserved": 1,
"started": 0,
"stopped": 0
},
"coupon_code": null,
"coupon_percentage": null,
"entirely_started": false,
"entirely_stopped": false,
"item_ids": [
"0fe80224-5914-441e-8dfc-5b97e4bb55c3"
],
"stock_item_ids": [],
"invoice_count": 0,
"total_tax_in_cents": 0,
"price_with_tax_in_cents": 13500,
"price_as_decimal": 135.0,
"price": 135.0,
"grand_total_as_decimal": 0,
"grand_total": 0,
"grand_total_with_tax_as_decimal": 0,
"grand_total_with_tax": 0,
"tax_as_decimal": 0,
"tax": 0,
"discount_as_decimal": 135.0,
"discount": 135.0,
"coupon_discount_as_decimal": 0,
"coupon_discount": 0,
"total_discount_as_decimal": 135.0,
"total_discount": 135.0,
"deposit_as_decimal": 0,
"deposit": 0,
"deposit_paid_as_decimal": 0,
"deposit_paid": 0,
"deposit_refunded_as_decimal": 0,
"deposit_refunded": 0,
"deposit_held_as_decimal": 0,
"deposit_held": 0,
"deposit_to_refund_as_decimal": 0,
"deposit_to_refund": 0,
"to_be_paid_as_decimal": 0,
"to_be_paid": 0,
"paid_as_decimal": 0,
"paid": 0,
"total_tax_as_decimal": 0,
"total_tax": 0,
"price_with_tax_as_decimal": 135.0,
"price_with_tax": 135.0,
"start_location": {
"id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"updated_at": "2020-11-05T15:11:02.151Z",
"created_at": "2020-11-05T15:11:02.151Z",
"name": "Default",
"code": "DFT",
"location_type": null,
"address": "",
"address_line_1": null,
"address_line_2": null,
"zipcode": null,
"city": null,
"region": null,
"country": null,
"archived_at": null
},
"stop_location": {
"id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"updated_at": "2020-11-05T15:11:02.151Z",
"created_at": "2020-11-05T15:11:02.151Z",
"name": "Default",
"code": "DFT",
"location_type": null,
"address": "",
"address_line_1": null,
"address_line_2": null,
"zipcode": null,
"city": null,
"region": null,
"country": null,
"archived_at": null
},
"customer": {
"id": "8b64a569-08ff-4075-9ede-be0e63cbf15a",
"updated_at": "2022-05-14T02:35:33.976Z",
"created_at": "2022-04-29T15:33:15.297Z",
"properties_attributes": {
"main": "Pode pedir pra liberar a reserva se entrar locação"
},
"avatar_url": "https://gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e.png?d=blank",
"archived": false,
"number": 1594,
"name": "INTERNO para o FOTÓGRAFO/VIDEOMAKER",
"email": "",
"tax_region_id": null,
"discount_percentage": 100.0,
"deposit_type": "none",
"deposit_value": 0.0,
"tags": [],
"address1": "",
"address2": "",
"city": "",
"region": "",
"zipcode": "",
"country": "",
"merge_suggestion_customer_id": null,
"legal_type": "person",
"main_address": "Pode pedir pra liberar a reserva se entrar locação",
"order_count": 4,
"turnover": 0.0,
"properties": [
{
"id": "e386e460-5bf2-4a13-bcc3-693d72a13e25",
"updated_at": "2022-05-14T02:35:33.993Z",
"created_at": "2022-04-29T15:33:15.305Z",
"name": "Main",
"type": "Property::Address",
"labels": true,
"print": false,
"owner_id": "8b64a569-08ff-4075-9ede-be0e63cbf15a",
"owner_type": "Customer",
"default_property_id": "eec352c0-4d5f-4d9a-b5b9-c8d81667e6bd",
"show_on": [],
"value": "Pode pedir pra liberar a reserva se entrar locação",
"position": 2,
"identifier": "main",
"attributes_hash": {
"first_name": "Pode pedir pra liberar a reserva se entrar locação",
"last_name": "",
"address1": "",
"address2": "",
"city": "",
"region": "",
"zipcode": "",
"country": "",
"value": "Pode pedir pra liberar a reserva se entrar locação"
},
"first_name": "Pode pedir pra liberar a reserva se entrar locação",
"last_name": "",
"address1": "",
"address2": "",
"city": "",
"region": "",
"zipcode": "",
"country": ""
}
],
"notes": [],
"orders": [
{
"id": "7e35583d-2309-4775-a993-d2277539da2f",
"updated_at": "2022-05-16T15:38:12.526Z",
"created_at": "2022-05-13T22:11:40.194Z",
"properties_attributes": {
"sublocacao": "Sim_Subloc"
},
"price_in_cents": 13500,
"grand_total_in_cents": 0,
"grand_total_with_tax_in_cents": 0,
"tax_in_cents": 0,
"discount_in_cents": 13500,
"coupon_discount_in_cents": 0,
"total_discount_in_cents": 13500,
"deposit_in_cents": 0,
"deposit_paid_in_cents": 0,
"deposit_refunded_in_cents": 0,
"deposit_held_in_cents": 0,
"deposit_to_refund_in_cents": 0,
"to_be_paid_in_cents": 0,
"paid_in_cents": 0,
"number": "9565",
"status": "reserved",
"starts_at": "2022-05-23T20:30:00.000Z",
"stops_at": "2022-05-24T19:15:00.000Z",
"customer_id": "8b64a569-08ff-4075-9ede-be0e63cbf15a",
"discount_percentage": 100.0,
"deposit_type": "none",
"deposit_value": 0.0,
"tags": [],
"tax_region_id": null,
"item_count": 1,
"coupon_id": null,
"tax_strategy": "inclusive",
"currency": "brl",
"shortage": false,
"location_shortage": false,
"payment_status": "Paid",
"start_location_id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"stop_location_id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"statuses": [
"reserved"
],
"status_counts": {
"concept": 0,
"new": 0,
"reserved": 1,
"started": 0,
"stopped": 0
},
"coupon_code": null,
"coupon_percentage": null,
"price_with_tax_in_cents": 13500,
"price_as_decimal": 135.0,
"price": 135.0,
"grand_total_as_decimal": 0,
"grand_total": 0,
"grand_total_with_tax_as_decimal": 0,
"grand_total_with_tax": 0,
"tax_as_decimal": 0,
"tax": 0,
"discount_as_decimal": 135.0,
"discount": 135.0,
"coupon_discount_as_decimal": 0,
"coupon_discount": 0,
"total_discount_as_decimal": 135.0,
"total_discount": 135.0,
"deposit_as_decimal": 0,
"deposit": 0,
"deposit_paid_as_decimal": 0,
"deposit_paid": 0,
"deposit_refunded_as_decimal": 0,
"deposit_refunded": 0,
"deposit_held_as_decimal": 0,
"deposit_held": 0,
"deposit_to_refund_as_decimal": 0,
"deposit_to_refund": 0,
"to_be_paid_as_decimal": 0,
"to_be_paid": 0,
"paid_as_decimal": 0,
"paid": 0,
"price_with_tax_as_decimal": 135.0,
"price_with_tax": 135.0,
"start_location": {
"id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"updated_at": "2020-11-05T15:11:02.151Z",
"created_at": "2020-11-05T15:11:02.151Z",
"name": "Default",
"code": "DFT",
"location_type": null,
"address": "",
"address_line_1": null,
"address_line_2": null,
"zipcode": null,
"city": null,
"region": null,
"country": null,
"archived_at": null
},
"stop_location": {
"id": "5fd490e2-83eb-4cf6-b453-4187c142de2b",
"updated_at": "2020-11-05T15:11:02.151Z",
"created_at": "2020-11-05T15:11:02.151Z",
"name": "Default",
"code": "DFT",
"location_type": null,
"address": "",
"address_line_1": null,
"address_line_2": null,
"zipcode": null,
"city": null,
"region": null,
"country": null,
"archived_at": null
}
}
]
},
"plannings": [
{
"id": "d7e8f4bc-1806-4c34-b3af-54069712057b",
"updated_at": "2022-05-13T22:12:35.367Z",
"created_at": "2022-05-13T22:11:57.744Z",
"order_id": "7e35583d-2309-4775-a993-d2277539da2f",
"item_id": "0fe80224-5914-441e-8dfc-5b97e4bb55c3",
"quantity": 1,
"price_each_in_cents": 11000,
"reserved": true,
"started": 0,
"stopped": 0,
"charge_label": "1 dia",
"charge_length": 86400,
"starts_at": "2022-05-23T20:30:00.000Z",
"stops_at": "2022-05-24T19:15:00.000Z",
"price_structure_id": null,
"price_tile_id": null,
"reserved_from": "2022-05-23T20:30:00.000Z",
"reserved_till": "2022-05-24T19:15:00.000Z",
"price_each_as_decimal": 110.0,
"price_each": 110.0,
"product": {
"id": "0fe80224-5914-441e-8dfc-5b97e4bb55c3",
"updated_at": "2021-10-20T19:45:25.930Z",
"created_at": "2020-10-27T15:06:03.878Z",
"name": "4×4 Carbon Fiber Matte Box",
"slug": "4x4-carbon-fiber-matte-box",
"sku": "4×4_CARBON_FIBER_MATTE_BOX",
"lag_time": 0,
"lead_time": 0,
"always_available": false,
"trackable": true,
"archived": false,
"archived_at": null,
"extra_information": "Valor de restituição: R$ 2.919.43",
"photo_url": "https://cdn3.booqable.com/uploads/a85d2d9fab1fb1739c974d1b9d31529d/photo/photo/7faffd5c-8b14-413a-9ebe-67b7b9153b50/large_fa032cb2-fd44-42e2-9766-fd94db2911a4.jpg",
"allow_shortage": false,
"shortage_limit": 0,
"sorting_weight": 0,
"description": null,
"show_in_store": true,
"base_price_in_cents": 11000,
"price_wrapper_id": null,
"price_type": "simple",
"price_period": "day",
"tax_category_id": null,
"flat_fee_price_in_cents": 0,
"structure_price_in_cents": 0,
"deposit_in_cents": 291943,
"discountable": true,
"taxable": true,
"quantity": 0,
"available_quantity": null,
"variation_values": [],
"product_group_id": "4993e85e-cbc0-4449-9901-841931e1df66",
"product_type": "rental",
"tracking_type": "trackable",
"photo_id": "7faffd5c-8b14-413a-9ebe-67b7b9153b50",
"base_price_as_decimal": 110.0,
"base_price": 110.0,
"flat_fee_price_as_decimal": 0,
"flat_fee_price": 0,
"structure_price_as_decimal": 0,
"structure_price": 0,
"deposit_as_decimal": 2919.43,
"deposit": 2919.43,
"photo": {
"id": "7faffd5c-8b14-413a-9ebe-67b7b9153b50",
"updated_at": "2021-12-24T10:30:02.955Z",
"created_at": "2020-10-27T15:06:03.902Z",
"owner_id": "4993e85e-cbc0-4449-9901-841931e1df66",
"owner_type": "Item",
"coordinates": {},
"position": null,
"preview": "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDACgcHiMeGSgjISMtKygwPGRBPDc3PHtYXUlkkYCZlo+AjIqgtObDoKrarYqMyP/L2u71////m8H////6/+b9//j/2wBDASstLTw1PHZBQXb4pYyl+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj/wAARCAAZABkDAREAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAECBAX/xAAiEAABBAICAQUAAAAAAAAAAAABAAIDEQQhEjETFCNBVGH/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8A2LF1YtA0AgEGBMJnS2GSGTfM10b1SC7gPdBgSOcPc5EgO1ekDyc6WNgLGt7ILqJBPwEEvXZH03oL5AIo7CCPjYHcg0X1dIGAAKAofiBoBAIBAIP/2Q==",
"original_url": "https://cdn3.booqable.com/uploads/a85d2d9fab1fb1739c974d1b9d31529d/photo/photo/7faffd5c-8b14-413a-9ebe-67b7b9153b50/fa032cb2-fd44-42e2-9766-fd94db2911a4.jpg",
"large_url": "https://cdn3.booqable.com/uploads/a85d2d9fab1fb1739c974d1b9d31529d/photo/photo/7faffd5c-8b14-413a-9ebe-67b7b9153b50/large_fa032cb2-fd44-42e2-9766-fd94db2911a4.jpg"
}
},
"stock_item_plannings": []
}
],
"notes": [],
"tax_values": [],
"lines": [
{
"id": "88aed5d7-02cc-4fb6-80ce-c71fea5f48d3",
"updated_at": "2022-05-13T22:12:33.821Z",
"created_at": "2022-05-13T22:11:57.763Z",
"title": "4×4 Carbon Fiber Matte Box",
"quantity": 1.0,
"position": 1,
"planning_id": "d7e8f4bc-1806-4c34-b3af-54069712057b",
"order_id": "7e35583d-2309-4775-a993-d2277539da2f",
"tax_category_id": null,
"has_price": true,
"charge_label": "1 dia",
"extra_information": "Valor de restituição: R$ 2.919.43",
"item_id": "0fe80224-5914-441e-8dfc-5b97e4bb55c3",
"discountable": true,
"taxable": true,
"parent_line_id": null,
"line_type": "charge",
"relevant": true,
"price_in_cents": 11000,
"price_each_in_cents": 11000,
"price_with_tax_in_cents": 11000,
"display_price_in_cents": 11000,
"price_as_decimal": 110.0,
"price": 110.0,
"price_each_as_decimal": 110.0,
"price_each": 110.0,
"price_with_tax_as_decimal": 110.0,
"price_with_tax": 110.0,
"display_price_as_decimal": 110.0,
"display_price": 110.0,
"properties": [
{
"id": "6d623ba2-e2d0-40fc-88e6-5eb1bd8af4b7",
"updated_at": "2020-10-27T15:09:34.706Z",
"created_at": "2020-10-27T15:09:34.706Z",
"name": "Valor de Restituição",
"type": "Property::TextField",
"labels": false,
"print": false,
"owner_id": "4993e85e-cbc0-4449-9901-841931e1df66",
"owner_type": "Item",
"default_property_id": "13e4b4ed-ca50-4e11-9a52-a053d7ef7404",
"show_on": [],
"value": "R$ 2.919.43",
"position": 1,
"identifier": "valor_de_restituicao",
"attributes_hash": {
"value": "R$ 2.919.43"
}
}
]
},
{
"id": "ed314a93-0a2f-4efe-b51d-80549c6540be",
"updated_at": "2022-05-13T22:12:33.821Z",
"created_at": "2022-05-13T22:11:59.917Z",
"title": "Subloc Filtro X",
"quantity": 1.0,
"position": 2,
"planning_id": null,
"order_id": "7e35583d-2309-4775-a993-d2277539da2f",
"tax_category_id": null,
"has_price": true,
"charge_label": null,
"extra_information": null,
"item_id": null,
"discountable": true,
"taxable": true,
"parent_line_id": null,
"line_type": "charge",
"relevant": true,
"price_in_cents": 1000,
"price_each_in_cents": 1000,
"price_with_tax_in_cents": 1000,
"display_price_in_cents": 1000,
"price_as_decimal": 10.0,
"price": 10.0,
"price_each_as_decimal": 10.0,
"price_each": 10.0,
"price_with_tax_as_decimal": 10.0,
"price_with_tax": 10.0,
"display_price_as_decimal": 10.0,
"display_price": 10.0,
"properties": []
},
{
"id": "c7f8b0e4-425a-4d55-b6f8-314b734bb957",
"updated_at": "2022-05-13T22:12:33.821Z",
"created_at": "2022-05-13T22:12:06.922Z",
"title": "Subloc Lente A",
"quantity": 1.0,
"position": 3,
"planning_id": null,
"order_id": "7e35583d-2309-4775-a993-d2277539da2f",
"tax_category_id": null,
"has_price": true,
"charge_label": null,
"extra_information": null,
"item_id": null,
"discountable": true,
"taxable": true,
"parent_line_id": null,
"line_type": "charge",
"relevant": true,
"price_in_cents": 1500,
"price_each_in_cents": 1500,
"price_with_tax_in_cents": 1500,
"display_price_in_cents": 1500,
"price_as_decimal": 15.0,
"price": 15.0,
"price_each_as_decimal": 15.0,
"price_each": 15.0,
"price_with_tax_as_decimal": 15.0,
"price_with_tax": 15.0,
"display_price_as_decimal": 15.0,
"display_price": 15.0,
"properties": []
}
],
"properties": [
{
"id": "9931a384-f1a5-4f85-95fd-1f45c0694f38",
"updated_at": "2022-05-16T15:38:00.982Z",
"created_at": "2022-05-13T22:11:54.348Z",
"name": "Sublocação?",
"type": "Property::Select",
"labels": false,
"print": false,
"owner_id": "7e35583d-2309-4775-a993-d2277539da2f",
"owner_type": "Order",
"default_property_id": "22af0cf1-4637-427b-b8f9-45c5c5c0b593",
"show_on": [],
"value": "Sim_Subloc",
"position": 4,
"identifier": "sublocacao",
"attributes_hash": {
"value": "Sim_Subloc",
"options": ""
},
"options": ""
}
],
"barcode": {
"id": "ad3c6a43-679e-40af-98fb-a70139f50ade",
"updated_at": "2022-05-13T22:11:40.249Z",
"created_at": "2022-05-13T22:11:40.249Z",
"number": "https://bqbl.it/ad3c6a43-679e-40af-98fb-a70139f50ade",
"owner_id": "7e35583d-2309-4775-a993-d2277539da2f",
"owner_type": "Order",
"barcode_type": "qr_code",
"image_url": "https://cdn3.booqable.com/uploads/a85d2d9fab1fb1739c974d1b9d31529d/barcode/image/ad3c6a43-679e-40af-98fb-a70139f50ade/aa1e2483-5d27-4a4b-8076-5d447c78d2ed.svg"
}
}
}

 

And on the next step the only option I have that contains these mentions is:
 

So appears to be flatten.
Maybe I'm missing something or I'm complicating things.
Thanks

Userlevel 1
Badge

Maybe something like this:
 


?

Userlevel 1
Badge

Actually looking closely, the last post refers to a json that have fields separated that's not my case.
I just want to parse all itens inside Order > lines > title that contains "Subloc" (or subloc).

Thanks

Userlevel 7
Badge +14

@Lucas Saldanha

You can use this data point as an input for the Code step to then split based on commas to create line items.

 

 

Then you can use Code to filter for only line items that have “Subloc”.

 

if you need help with the Code step, consider hiring a Zapier Expert: https://zapier.com/experts

Userlevel 1
Badge

Thank you.
I've tried, but only returns one item. Programming is not a strong suit for me :(
Maybe have to do a "for each" or something like that?
This is what I'm using:
 

let Content = inputData.Content;
let sublocitem = Content.split("Subloc")[1].split(",")[0].trim();

output = [{sublocitem}];

There's no way of zapier to pass individual items to the next step without the need to do a script?
Thank you very much

Userlevel 7
Badge +12

Hi @Lucas Saldanha 
Yes, what Troy is suggesting would be to use something like a forEach to filter out line items that don’t have “Subloc” in them. Zapier collapses line item data (by like keys) so that is what you are experiencing. Zapier is taking the Order Lines array and collapsing the objects by their keys so you end up with Order Lines Title which has the values of all the line item titles separated by commas.


Code would be the most efficient way to only send the titles you are interested in. 

//assumed that your titles are in a field 'Content'
let Content = inputData.Content;

//split the text field back into an array, splitting at every comma
//note this can have negative effects if any of your titles have commas in them.

let sublocitems = Content.split(",");

let individualObjects = {};

sublocitems.forEach((item,index) => {

//check if the item has the word "Subloc" in it
if (item.toLowerCase().includes("subloc")) {
individualObjects[`item ${index}`] = item;
}
})

return individualObjects



OUTPUT:

 

Userlevel 1
Badge

@GetUWired thank you very much, this is perfect!
One more detail if possible: if I would like to get Subloc and subloc (ignoring case sensitiviy), how would I change the code?

Thank you very much,

Best Regards,

Userlevel 1
Badge

Hi @GetUWired how is everything?
One more question. Since I'm using a code to split the items, on the next step would be to create tasks.

But I can only choose one "field" on the task (referencing 1 item only). And I would like to create 2 tasks if it has 2 items, 3 if it has 2, 5 if it has 5 and 1 if only have 1.

I've looked into the looping by Zapier but couldn't find anything to work with.
Best Regards

Userlevel 7
Badge +12

Hi Lucas!

Sorry for just now getting back to you! 

I will answer your questions in order.. 

First, the code is not case sensitive “subloc”, “SUBLOC”,”Subloc” or any other combination would all match. Thats what the item.toLowerCase() part of the code does. 

Second, the code currently just outputs all items as individual indexed items.. There are a couple of ways you could modify the code to run a loop. The easiest of which would just be to have the code return a list of objects (Zapier will then enter into a loop for each object returned). In testing, it will look as though there is only 1 item found. 

//assumed that your titles are in a field 'Content'
let Content = inputData.Content;

//split the text field back into an array, splitting at every comma
//note this can have negative effects if any of your titles have commas in them.

let sublocitems = Content.split(",");

let individualObjects = {};
let allSublocItems = [];

sublocitems.forEach((item,index) => {
individualObjects = {};

//check if the item has the word "Subloc" in it
if (item.toLowerCase().includes("subloc")) {
individualObjects['item'] = item;
individualObjects['loop index'] = index
allSublocItems.push(individualObjects)
}
})

return allSublocItems





Given the additional details, it sounds like another way you could have accomplished this without code would have been to use Looping By Zapier in place of the code block, and then inside of the loop, you would put a filter step to only continue if the item name contains ‘subloc’.

Userlevel 1
Badge

Thanks a lot @GetUWired! I'll test here.
Best Regards,