Question

Output data to Notion different when running Zap automatically

  • 13 May 2023
  • 2 replies
  • 28 views

Userlevel 1

Hi,

 

I have built a Zap that’s trigger when a new form submission is sent from Jotform.

 

The output data from Jotform is sent as a text string looking like this:

Artikel 1: Artikelnamn = C5860, Artikelnummer = JGF67458, Antal = 1, Inpris = 75000, Artikel 2: Artikelnamn = Finisher extern, Artikelnummer = 234341, Antal = 1, Inpris = 16000, Fraktartikel: Artikelnamn = Frakt, Antal = 1, Inpris = 2450, Utpris = 2450, Retur: Artikelnamn = Retur, Antal = 1, Inpris = 800, Utpris = 800

 In the next step in my Zap I want to create a database item in Notion. I want to populate different properties with data from the output above. So I have in property for “Artikelnamn”, one for “Artikelnummer” and so on.

 

To mange to do this I’ve use the Code by Zapier and I’m using the following code:

# Check if the input_data contains a dictionary with an 'input_text' key

if isinstance(input_data, dict) and 'input_text' in input_data:

    # Get the input text from the 'input_text' key

    input_text = input_data['input_text']

else:

    # Otherwise, assume the input_data is a string and set input_text to that value

    input_text = str(input_data)

# Use regular expressions to replace square brackets, quotation marks, vertical bars, curly brackets, single quotes, colons, Artikel, and artikelnamn with a space

import re

output_text = re.sub(r'(\[|\]|"|\\|\/|\||\n|\r|{|}|:|\')|(Artikel|artikelnamn)', ' ', input_text)

# Set the output value of the 'output_text' field to the modified text

output = {'output_text': output_text}

 

When I Manually run all the steps in my Zap it works just fine. The text is split the way I want to and the database item is created in Notion just the way I want it to.

 

However, when I turn on the Zap and it runs automatically it doesn’t work the way I want it to. The output data isn’t the same. My Zap adds text to the out put data

What am I missing? 😊

 

Regards Joel

 

 

 

 


2 replies

Userlevel 7
Badge +14

Hi @Joel Lager 

Good question.

 

In the Code step, you are missing an Input Data variable name, which may be contributing to the issue.

 

With your Zap ON, do a test, then check your Zap Runs history details to see the DATA IN/OUT for each Zap step to help you troubleshoot: https://zapier.com/app/history/

Userlevel 1

Hi, 

Thanks and that’s a good observation. I’ve tried to add the Input Data name and there is no difference in the result. 

I’ve looked in the history for the Zap and looked into the input and output data. The output data is the same as the data that’s put into Notion. So in a way that’s correct. 

So when the Zap runs automatically I get: “Maskinkropp namn = C3540i
But when i run in manually by testing each step I get:  “C3540i”.

 

Any other suggestions? 

 

Regards Joel :) 

Reply