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 = “https://api.pipedrive.com/v1/deals/8350?api_token=xxxxxxxxxxx”;
var response = UrlFetchApp.fetch(url);
var dataSet = JSON.parse(response.getContentText());
var data;
data = dataSet.data[0];
Browser.msgBox(data.title);
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 https://api.pipedrive.com/v1/deals/5555?api_token=xxxxxxxxxxxxxx
{“Success”: true, “data”: {“title”: “Test Titlel”, “200a8f1bbf06942f7270c24bc35ff235ade3e”: “2018-03-12”}, “additional_data”: …
You can simply add an option parameter to the UrlFetchApp.fetch method, like this.
var url = 'https://api.pipedrive.com/v1/deals/?api_token=xxxxx';
var data = {
"title": "New Deal"
};
var options = {
"method": "post",
'contentType': 'application/json',
"payload": JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);
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…
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];
CreatePipedriveDeals(UserID);
return ContentService.createTextOutput(e.parameters)
}
function CreatePipedriveDeals(UserID) {
var url = 'https://api.pipedrive.com/v1/deals/?api_token=dbdjsbdxxxxxx';
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);
}