None Type Object Does Not Support Item Assignment Definition

How to Get Started with Code (JavaScript) on Zapier#

Looking for Python instead of JavaScript? Visit our Code (Python) documentation.


With Zapier's Code action you can extend our platform to do just about anything using the most ubiquitous programming language on the web - JavaScript! Run code in response to any trigger that Zapier supports.

Some example use cases include:

  • Transform incorrect dates or convert between other data types.
  • Use custom regular expressions to extract extra data like emails or tracking numbers from large text blobs.
  • Make an extra API call to a different service with without building a full dev app.
  • Augment data from a trigger with extra data from some other source (either generated or external API).
  • Anything else you can dream up!

Warning - this is advanced stuff! You probably need to be a programmer to use this - though you are welcome to play with it. Technical support for bugs in your code is not provided!

How does it work?#

The environment is vanilla node.js v4.3.2 which runs JavaScript. Your script is sandboxed and can only run for a limited amount of time and within a limited amount of memory. If you exceed those limits - your script will be killed (you can upgrade to a paid Zapier to increase your limits).

Since the amount of data that might feed into your script might be large or highly dynamic - you'll need to define an inputData mapping via our GUI. This is a really simple step - the screenshot below shows a very basic example:

Scroll to the examples section to see an assortment of starter scripts.

In your code you will have access to a few variables:

Data Variables#

  • The mapping of data you did right above your code snippet (not available in triggers). All values will be strings.
  • An object or array of objects that will be the "return value" of this code. You can explicitly return early if you like.

Setting the to an array of objects will run the subsequent steps multiple times — once for each object in the array. If Code by Zapier is the Zap's trigger and an empty array is returned, nothing happens.


  • (optional) A callback if you need to do async work - whatever you set to the data variable is ignored since you provide it directly here. We inspect your code and make our best guess if you are using or not!

    • Important: Invoking tells Zapier that your task is done executing. If you have multiple asynchronous calls, each invoking with their desired responses, only the first one to execute will count. Subsequent invocations to will be picked up by the next execution of your Zap, but will not affect that task's execution (other than side effects like, for example, calls). Be sure to carefully manage when you use to avoid extremely tricky and confusing bugs!
  • An easy to use HTTP client - read the documentation here.

  • Super helpful if you want to debug your function - you'll need to test your zap to see the values (the logs are returned to you in a added automatically to your ).


Running your zap via the dashboard is the canonical way to confirm the behavior you expect - your Task History will have all relevant details around the ran code's inputData, output and logs. The test step in the editor can be used for a tighter feedback loop.

Try asking for help by tagging questions as Zapier on Stackoverflow!

↑ Was this documentation useful? YesNo (Suggest Edits)

Code (Javascript) Examples#

Important! Every example depends on specific - which is provided under the "Input Data" field when setting up your - this example screenshot shows three demonstration inputs you can use in your code like this: , , and . Be sure you read the code examples and provide the right inputs otherwise nothing will work as expected!

In this section we provide some examples - it is important to note that javascript is an advanced programming language - if you get lost it might make sense to ask a programmer friend or learn javascript yourself.

Introductory Examples#

Each of the four examples below expects a in the "Input Data" field.

A synchronous example might be something as trivial as:


You can also bind the result to - the code above has exactly the same behavior as the code below:


You'll notice that when it comes to code - you can solve the same problems in hundreds of unique ways!

A synchronous example with an early empty return might be something as trivial as:

if('Larry'){return[];// we don't work for Larry!}return{id:1234,hello:'world!',};

If Code by Zapier is the Zap's trigger and you return an empty array , we will not trigger any actions downstream — it is as if you said "nevermind" in code.

An asynchronous example might be something as trivial as:


Introductory HTTP Example#

A more complex asynchronous example (no "Input Data" needed):


Very important - be sure to use in asynchronous examples!

Introductory Logging Example#

This example expects a in the "Input Data" field:

if({console.log('got name!',;}return{id:1234,hello:'world!',};

Test your action and look at the data to see the result - great for debugging your code!

Simple Math - Divide by Two#

This example expects a in the "Input Data" field:


Simple Email Extraction#

This example expects a in the "Input Data" field:


Complex Multiple Email Extraction#

This example expects a in the "Input Data" field:


Because this returns an array like instead of a single object like - this will activate follow up actions multiple times - one for each email found! If no emails are found - nothing happens.

Weather JSON API Call#

This example expects a in the "Input Data" field:


Store State#

It isn't uncommon to want to stash some data away for the next run, our can do exactly that. For example - this is a counter that counts how many times it is ran:

varstore=StoreClient('your secret here');varoutCount;store.get('some counter').then(function(count){count=(count||0)+1;outCount=count;returnstore.set('some counter',count);}).then(function(){callback(null,{'the count':outCount});}).catch(callback);

Read more about StoreClient here.

↑ Was this documentation useful? YesNo (Suggest Edits)

StoreClient (Javascript)#

Storing and retrieving data with is very simple.

There is no need to require it - it comes pre-imported in your Code environment.

You will need to provide a secret that will protect your data. I recommend using's excellent password generator. Be very sure you pick a complex secret - if anyone guesses it they'll be able to read and write your data!

Instantiating a client is very simple:

varstore=StoreClient('your secret here');

is a promise based library - get ready for some and action.

Most likely you just want to and some values - this is the simplest possible example:

varstore=StoreClient('your secret here');store.set('hello','world').then(function(){returnstore.get('hello');}).then(function(value){// value === 'world'returnstore.delete('hello');}).then(function(){callback();}).catch(callback);

If the value doesn't exist during your call - it will return a value.

Bulk Operations#

You can also save and retrieve multiple keys and values - a slightly more complex example:

varstore=StoreClient('your secret here');store.setMany({hello:'world',foo:'bar'}).then(function(){returnstore.getMany('hello','foo');}).then(function(values){// value === {hello: 'world', foo: 'bar'}returnstore.deleteMany('hello','foo');}).then(function(){// or, if you want to wipe everythingreturnstore.clear();}).then(function(){callback();}).catch(callback);

Note, you can call and in a few different ways:

store.getMany('hello','foo');// as argumentsstore.getMany(['hello','foo']);// as arraystore.getMany({hello:null,foo:null});// as object


You can also access the stored data via our store API. More info at


  • Any JSON serializable value can be saved.
  • The secret must be under 32 chars in length.
  • Every key must be under 32 chars in length.
  • Every value must be under 250 kb.
  • Only 500 keys may be saved per secret.
  • Keys will expire if you do not touch them in 3 months.

↑ Was this documentation useful? YesNo (Suggest Edits)

Common Problems with Code (Javascript) on Zapier#

I need help!#

Try asking for help by tagging questions as Zapier on Stack Overflow!

Error: Scripting payload too large#

The environment in which your Code steps run (AWS Lambda) has an I/O limit of 6MB. The total size of the code and the data processed by the code cannot exceed that. If you're hitting this error, try to limit the amount of data your return from your function. For instance, don't return an entire JSON structure, just the keys you need.

I keep getting "Process exited before completing request" - what gives?#

9 times out of 10 this happens if your script completes without calling the - the most common case is if your doesn't have a for errors. A simple will suffice because the error will be passed as the first argument.

'NoneType' object does not support item assignment#

This shows up when you redefine some of the important variables in the function, namely . Lambda expects to be there to complete an async function, so if you've redefined it you'll get some strange errors.

Requiring or Using External Libraries#

Unfortunately you cannot require external libraries or install or import libraries commonly referred to as "npm modules". Only the standard node.js library and the package are available in the Code app. is already included in the namespace.

Time & Memory Limits#

Free users are limited to and . Paid users get well over double that at and . Your Zap will hit an error if you exceed these limits.

I am getting various SyntaxErrors and other weird bugs.#

Javascript is a fairly complex language and you should probably be a programmer or willing to dedicate some serious time to learn to code - while we can't help you fix your code (try asking for by tagging questions as Zapier on Stackoverflow) - here are some helpful tools:

Use a Linter#

Linters do an amazing job of letting you know when things are broken - for example - we love and you can paste your code directly there! For example, let's say our code looks like this and we keep getting an error about not being defined:

// this is bad code - but we don't know why...fetch('').then(function(res){returnres.text();}).then(function(body){callback(null,{id:1234,rawHTML:response});}).catch(function(error){callback(error);});

The error is driving us crazy! Now in we paste this (note the extra globals definition so jshint knows about Zapier's provided variables):

/* globals inputData, output: true, fetch, callback */// this is bad code - but we don't know why...fetch('').then(function(res){returnres.text();}).then(function(body){callback(null,{id:1234,rawHTML:response});}).catch(function(error){callback(error);});

If we look at the results we see that is indeed incorrect! We should have used :

You can safely ignore any warnings about "unused variables" of , , or ! We provide those for your convenience - you don't need to use them. But if you see something else listed there - it might be a sign that you have a bug!

↑ Was this documentation useful? YesNo (Suggest Edits)

Popular things to do with Code (Javascript) on Zapier#

Check out the Code Examples section of this article!

Posts: 1,915
Threads: 62
Joined: Sep 2016
Reputation: 99
Likes received: 603


Oct-20-2017, 02:57 PM (This post was last modified: Oct-20-2017, 02:57 PM by snippsat. Edited 2 times in total.)
You are not getting the form,so it return None.
>>> form = None >>> form['something'] = '****'The problem here is that log in use JavaScripts here with AngularJS.
RoboBrowser dos not evaluate JavaScript,so then have to reverse engineering what Angular dos to do the same.
Or simpler use Selenium/PhantomJS to do this.
Example it will try to log in:
from selenium import webdriver from bs4 import BeautifulSoup import time   # Activate Phantom and deactivate Chrome to not load browser #browser = webdriver.PhantomJS() browser = webdriver.Chrome() web_url = '' browser.get(web_url) user_name = browser.find_element_by_xpath('//input[@ng-model="pageState.username.value"]') user_name.send_keys("Foo") password = browser.find_element_by_xpath('//input[@ng-model="pageState.password.value"]') password.send_keys("Bar") time.sleep(2) submit = browser.find_element_by_css_selector('#submitButton') '''  # Give source code to BeautifulSoup soup = BeautifulSoup(browser.page_source, 'lxml') welcome ='//title') print(welcome.text) '''

One thought on “None Type Object Does Not Support Item Assignment Definition

Leave a Reply

Your email address will not be published. Required fields are marked *