I am creating a new card in trello board from JS function
var currentLocation = window.location.href;
function AddCardToTrello() {
Trello.addCard({
url: currentLocation,
name: "{{ soproduct.product }}",
due: {{ soproduct.required_date|date:"SHORT_DATE_FORMAT" }}
});
}
After the creation, I am getting a Trello wizard that displays me with the link to the newly created card on Trello board. I wand to capture this link and save it on my backed . How can I do it ? Is it possible to capture the data from same API call?
I just tested this on the Trello Sandbox:
var destinationList = "XX_YOUR_LIST_ID_XX";
var success = function(successMsg) {
asyncOutput(successMsg);
};
var error = function(errorMsg) {
asyncOutput(errorMsg);
};
var newCard =
{name: "I just created a new card!",
desc: "Using the Trello API is fun and easy!",
pos: "top",
due: null,
idList: destinationList
};
Trello.post('/cards/', newCard, success, error);
The successMsg
callback value contains a param in the object:
"url": "https://trello.com/c/PCJcEkmm/6-i-just-created-a-new-card"
So my suggestion would be to add the process to save to backend, to your success function - depending on your plugin/script architecture used.
var success = function(successMsg) {
console.log(successMsg);
//Save to storage here
};
var error = function(errorMsg) {
console.log(errorMsg);
};
function AddCardToTrello() {
Trello.addCard({
url: currentLocation,
name: "{{ soproduct.product }}",
due: {{ soproduct.required_date|date:"SHORT_DATE_FORMAT" }}
}, success, error);
}