Post

3 followers Follow
0
Avatar

Ongoing Log for Incoming and Outgoing texts

I have a communications app where all my incoming and outgoing texts are inputted after coming in or going out. Each text creates a new item. I would like to have a complete ongoing log in my seller leads app that relates to the communications app. So if the seller sends me 2 texts, I would like both those texts, as well as any texts that I send to them, show up in a calculations field in my seller leads app. 

I am pretty sure that the calculation should start out with

var type = @All of Type;
var created = @All of Created On;
var text = @All of Text Message with nulls;
var number = @All of Contact Number;

type.length +  " "  + created.length +  " "  + text.length;

but if I just leave it like this it only tells me how many texts that are there, it does not show what I would need it to show which is

the type (incoming/outgoing) - this is a field in the communications app

date of text - which is also on the communications app

the text - what the incoming or outgoing text says

the number I added cause I thought it would be needed to know which lead the text belongs to.

Please help so that I can have this log instead of having to go searching for that text.

Helen Tinges

Please sign in to leave a comment.

5 comments

0
Avatar

Hi Helen,

the Javascript method .length counts something. 

var word = "Helen";
word.length 
returns 5, cause "Helen" has 5 characters. 

When you call something with @all of  you get an array of items, f.ex. 
@all of type 
is 
["incoming","incoming","outgoing","incoming","outgoing"]
(the square brackets indicate that this is an array).

This array has 5 elements (items). Using .length on an array returns the number of elements: type.length = 5 in this case. 

To make an array readable you need to parse it to string, either with .join() or .toString() (there are also other methods, but these 2 are the most used). 

For concatenating the right type to the right text to the right date to the right contact you must use a for loop (in this forum are dozens of examples). 

The exact code depends on how you want to display the log entries. If you can give me an example how the log should look like I think I can show you the correct code.

Rainer 

 

Rainer Grabowski 0 votes
0
Avatar

Something along the lines of this. I have 2 separate apps, one for calls and the other for texts. The calls are done with call rail so I wasn't sure if I needed to pull the recording using glowbiflow before using the code in order to have the log show in that way. Then the texts, I do not care about the green envelope which I am assuming by the looks of it is an outgoing msg.

Helen Tinges 0 votes
0
Avatar

Hello Helen,

I assume that Created On is a real Date field or a date type calculation field. 

var type = @All of Type;
var created = @All of Created On;
var text = @All of Text Message with nulls;
var logs = [];
for(var i = 0; i < created.length; i++){
logs.push(type[i] + " " + moment(date[i]).tz("America/Chicago").format("DD MMM YYYY h:mm A") + "\n" + text[i][0]);
};
logs.join("\n\n")

Rainer

Rainer Grabowski 0 votes
0
Avatar

Yes.

Btw: Here .tz("America/Chicago") you have to enter your timezone. 

Rainer Grabowski 0 votes