Best answer

Javascript with Monday.com

  • 8 September 2020
  • 8 replies
  • 389 views

Userlevel 1

Hi, Im trying to make a Zap between Monday and Followupboss. Unfortunately Monday’s side dosen’t pick up the columns that I need to send over to Followupboss.

 

I’ve managed to get a JSON query setup to pick up the values from Monday with this:

query {

  boards(ids: xxxxxxxx) {

    items {

      column_values(ids: ["telefon", "e_post", "plats",]) {

        title

        text

        id

      }}}}

 

With this I guess I need to setup a Javascript with Code by Zapier but Im not sure how to move forward from here. Is Javascript the way to go? If so, I have never used Javascript and is this something that requires a lot of experience?

icon

Best answer by Mercology 8 September 2020, 20:26

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.

8 replies

Userlevel 4
Badge +5

@Robin.H  To do this in the Code atep, you need to:

  1. Get the Authorization Key from you Monday.com account
  2. Build the query string as JSON
  3. Complete the code and test.

Here is a code snippet you can use to complete this task:

//
//Set the authorization key
//
var authKey = "xxxxxxxxxxxx";
//
//Build query as JSON - must be one string
//
var myQuery = JSON/stringify({“query”: {boards(ids: xxxxxxxx) {items { column_values(ids: [\"telefon\", "\e_post\", "\plats\"]) {title text id}}}}
//
//Build GET options
//
const options = {
url: 'https://api.monday.com/v2/',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': authKey
},
params: myQuery
}
//
//Send the request
//
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response.content);
});
//
//Return the results
//
return results;

 

Userlevel 1

@Mercology Thank you so much for your answer!

I took the code, added the authKey and added the board ids.
When I then ran it I got this error.

“SyntaxError: Invalid or unexpected token”

So I removed all the comments incase that was causing the problem. But I got the same Syntaxerror. 

Any idea where I messed up?

 

Userlevel 4
Badge +5

Replace JSON/stringify with JSON.stringify

 

Userlevel 1

Tried it now, still SyntaxError with that change.  

Do I need a “ ,  “ or a “  ;  “  after the } which closes the Const Options?
 

Userlevel 4
Badge +5

Let’s try using a Javascript template for the variables in the query:

 

Replace the current var myQuery… with the following:

var boardId="xxxxx";  //if this is a number, remove the quotes...
var field1="telefon";
var field2="e_post";
var field3="plats";
var myQuery = `"query": {boards(ids: ${boardId}) {items {column_values(ids: [\"${field1}\", \"${field2}\", \"${field3}\"]) {title text id}}}}`;

If this doesn’t work, are you available for a Zoom call?  Let me know, happy to jump on to debug.

David

Userlevel 1

Ye still SyntaxError.

 

Ye Im available, any time today! Once again, thank you so much for helping me out!

Userlevel 1

Hey again, I realise there is quite the timezone differens between the US and Sweden :sweat_smile:

I will discuss this with my colleagues on monday and see if this is the way for us to solve this problem or if its out of our scope. Or maybe a solution for the future!

Incase we choose to try this way, what is the easiest way for me to contact you and setup a zoom call?

Thanks again!

Userlevel 4
Badge +5

The syntax is the tricky part as we are converting a GraphML query into JSON.  Once we get the syntax, this will work.  I will private message you about getting together in Zoom.