Google Scripts in a deal vs Pipedrive

How can I get a data in google scripts of a deal? For example: data.title
What am I doing wrong in my code
Thnx in advance.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(“Pipe”);
var url = “”;
var response = UrlFetchApp.fetch(url);
var dataSet = JSON.parse(response.getContentText());
var data;
data =[0];

Since you’re requesting a specific deal, there’s no need to get the first element with data[0].
You should probably simply do

data =;

Can you try that and see if it works? :slight_smile:

1 Like

Yes, its work!. Thanks god dani!

1 Like

No worries. Glad it helped :slight_smile:

Perfect with

But i have my Json with
{“success”:true,“data”:{“title”:“Test Titlel”,“200a8f1bbf06942f7270c24bc35ff235ade3e”:“2018-03-12”},“additional_data”:…

with data.title i parse de titlte, perfect.

but how can i parse that 200a8f1bbf06942f7270c24bc35ff235ade3e, i need that “date”

Thanks in advance.

That one looks like a custom field.

You need to make another call to (or /personFields, /activityFields, etc.) to get the list of fields, and then match the key to get the name of the field.

Let me know if that helps.

Thanks Daniel, you are a genius!
I make a match in / personField, it gives me the correct field, but I would also need “the date” that it gives me as an answer
{“Success”: true, “data”: {“title”: “Test Titlel”, “200a8f1bbf06942f7270c24bc35ff235ade3e”: “2018-03-12”}, “additional_data”: …

Do you mean this?


Genius! I needed that.
Thank you, thank you very much!!!.

1 Like

Nice! :smile:
You’re super welcome.

Hi there :wave:

You can simply add an option parameter to the UrlFetchApp.fetch method, like this.

var url = '';
var data = {
    "title": "New Deal"
var options = {
    "method": "post",
    'contentType': 'application/json',
    "payload": JSON.stringify(data)
var response = UrlFetchApp.fetch(url, options);

You can find all the details on the Google Script documentation (that’s how I figured it out as well).
here: Class UrlFetchApp  |  Apps Script  |  Google Developers

Dani, thans, your code its ok
But i need, “upload a file of google drive, to a DEAL, with Json”.
Can you help me?
Thanks in advance.

Then it’s probably slightly different from simply adding a deal. I would suggest looking into Google Script’s documentation.
Here are the links you need to read…

Pipedrive’s API reference for adding files:!/Files/post_files
Google Script documentation:


Thanks Dani i see that links.

Hi Dani,

I’m trying to build a logic where based on “To” param from my cloud telephony, I’ll create a deal dynamically for a specific. Created array as well in row 3 but getting truncated server response:

var ID = "1xtkrT0LTnSqxuU8rrxxxx"
var SHEET_NAME = "Miss call Assignment"
var UserID = { "08046810620": "4421772", "08046810617": "5070776", "08046810618": "6272609", "08046810620": "5839454", "08046810616": "5709457", "08047104949": "8496220", "8046810616": "5709457" }

function doGet(e) {
    var params = JSON.stringify(e.parameters);
    var jsonMapping = JSON.parse(params)
    var sheet = SpreadsheetApp.openById(ID).getSheetByName(SHEET_NAME)
    sheet.appendRow([jsonMapping["From"][0], jsonMapping["To"][0], jsonMapping["CurrentTime"][0]])
    var Customernum = jsonMapping["From"][0];
    var timePeriod = jsonMapping["CurrentTime"][0];
    var agentnum = jsonMapping["To"][0];
    return ContentService.createTextOutput(e.parameters)

function CreatePipedriveDeals(UserID) {
    var url = '';
    var formData = {
        'user_id': "" + UserID,
    var data = {
        "title": "New Deal test anuj 1",
        "user_id": "formData",
        "stage_id": "259",
        "status": "open"

    var options = {
        "method": "post",
        'contentType': 'application/json',
        "payload": formData
    var response = UrlFetchApp.fetch(url, options);