Using Podio Calculation Fields to Show Call/SMS History

//Using Podio Calculation Fields to Show Call/SMS History

One of the greatest benefits of using smrtPhone as a Podio user is that it’s built specifically to integrate with Podio. All of your calls and SMS messages will be stored in your Communications app. Once they’re in there, depending on your needs and tastes, you can use a myriad of options from both Podio and Globiflow (or a third party service) to report on these communications. The sky is truly the limit.

We’ve been testing a number of different options since we launched and now I want to share with you one possible scenario that’s really working for both us and our clients. All the magic takes place inside two Podio calculation fields, and we leverage two external services, dabuttonfactory.com and shields.io, in order to provide us with some dynamic graphics.

Before we discuss the history fields, we need a couple of additions to our Communications app to make this work. First, we installed a new calculation field and used the @Created On tag to store the date the record was created. Second, we are using a single line text field to store the “URL Link to Item” from Globiflow, and have written a flow that fires upon the creation of each new record to store the URL so it can be used elsewhere. Once you have made both of these changes, everything else in this next section will work.

There isn’t really enough time to explain every nitty-gritty detail of these fields, but allow me to give a brief overview of what this code is designed to do. First, we want to collect all of the records in your Communications app that are connected to the Contact in question. Then, we sort them out into both Incoming/Outgoing Call and Text so we can display the interactions in separate fields. We build an array of these items so we can then sort them by date, and the fields are set up to display the most recent interactions on the top. Finally, using dabuttonfactory.com and shields.io, we display either an image indicating there are no associated records, or, we display:

  • For calls, we show the date and time, the direction of the call, which smrtPhone Number was involved, the Call Owner and the Call Notes.
  • For SMS, we show the date and time, the direction of the message, which smrtPhone Number was involved, and the message itself.

Because you could have dozens or even hundreds of calls/text messages for a particular contact, which would make the fields unmanageable, we truncate the records and show a message indicating there are more that aren’t shown. You can always scroll down to the Related Items to view all communications for the Contact.

Okay, enough exposition, here’s the code for the two fields:

Call History

var table = "";
var type = @All of Type;
var dt = @All of Created On;
var owner = @All of Call Owner with nulls;
var url = @All of URL;
var note = @All of Call Notes with nulls;
var smrt = @All of smrtPhone Number;
var count = 0;
var ints = [];
for (var i = 0; i < type.length; i++){
if (type[i] == "Incoming Call" || type[i] == "Outgoing Call") {
ints[i] = {date: moment(dt[i]).format("MM/DD/YYYY h:mm A"),type: type[i],owner: owner[i],url: url[i],note: note[i], smrt: smrt[i]}; count++
}};
ints.sort(function(a,b){
return new Date(b.date) - new Date(a.date);
});
var trunc = "";
for (var j in ints) {
if (j == 4) {
trunc = "\n" + "![image](https://dabuttonfactory.com/button.png?t=" + (count-4) + "+Interactions+Not+Shown&f=Calibri-Bold&ts=16&tc=fff&tshs=1&tshc=000&hp=13&vp=3&c=5&bgt=gradient&bgc=3d85c6&ebgc=073763)"; break;
};
if (ints[j].type == "Incoming Call") {
table += "[![image](https://img.shields.io/badge/" + ints[j].date + "-INCOMING CALL-green.svg)](" + ints[j].url + ") " + "![image](https://img.shields.io/badge/smrtPhone Number-" + smrt[j] + "-blue.svg)" + "\n" + ints[j].owner + ": " + ints[j].note + "\n " + "\n " + "\n";
};
if (ints[j].type == "Outgoing Call") {
table += "[![image](https://img.shields.io/badge/" + ints[j].date + "-OUTGOING CALL-red.svg)](" + ints[j].url + ") " + "![image](https://img.shields.io/badge/smrtPhone Number-" + smrt[j] + "-blue.svg)" + "\n" + ints[j].owner + ": " + ints[j].note + "\n " + "\n " + "\n";
}};
if (table == "") {
table = "![image](https://dabuttonfactory.com/button.png?t=No+Call+History&f=Overlock&ts=22&tc=fff&tshs=1&tshc=000&hp=20&vp=8&c=3&bgt=gradient&bgc=c00&ebgc=e06666)";
};
table + trunc

SMS History

var table = "";
var type = @All of Type;
var dt = @All of Created On;
var text = @All of Text Message with nulls;
var url = @All of URL;
var smrt = @All of smrtPhone Number;
var count = 0;
var ints = [];
for (var i = 0; i < type.length; i++){
if (type[i] == "Incoming Text" || type[i] == "Outgoing Text") {
ints[i] = {date: moment(dt[i]).format("MM/DD/YYYY h:mm A"),type: type[i],text: text[i], url: url[i], smrt: smrt[i]}; count++
}};
ints.sort(function(a,b){
return new Date(b.date) - new Date(a.date);
});
var trunc = "";
for (var j in ints) {
if (j == 4) {
trunc = "\n" + "![image](https://dabuttonfactory.com/button.png?t=" + (count-4) + "+Interactions+Not+Shown&f=Calibri-Bold&ts=16&tc=fff&tshs=1&tshc=000&hp=13&vp=3&c=5&bgt=gradient&bgc=3d85c6&ebgc=073763)"; break;
};
if (ints[j].type == "Incoming Text") {
table += "[![image](https://img.shields.io/badge/" + ints[j].date + "-INCOMING SMS-green.svg)](" + ints[j].url + ") " + "![image](https://img.shields.io/badge/smrtPhone Number-" + ints[j].smrt + "-blue.svg)" + "\n" + ints[j].text + "\n" + "\n" + "\n --- \n";
};
if (ints[j].type == "Outgoing Text") {
table += "[![image](https://img.shields.io/badge/" + ints[j].date + "-OUTGOING SMS-red.svg)](" + ints[j].url + ") " + "![image](https://img.shields.io/badge/smrtPhone Number-" + ints[j].smrt + "-blue.svg)" + "\n " + ints[j].text + "\n" + "\n" + "\n --- \n";
}};
if (table == "") {
table = "![image](https://dabuttonfactory.com/button.png?t=No+SMS+History&f=Overlock&ts=22&tc=fff&tshs=1&tshc=000&hp=20&vp=8&c=3&bgt=gradient&bgc=c00&ebgc=e06666)";
};
table + trunc

All you should have to do is create new calc fields in your Contacts app, and drop in this code and change the @ tags to actual ones inside your app. If you have any questions, please drop us a line in the smrtPhone Users workspace and we can walk you through it. Have fun!

 

 

By | 2018-01-29T15:47:37+00:00 January 29th, 2018|smrtPhone Features|Comments Off on Using Podio Calculation Fields to Show Call/SMS History