Post

2 followers Follow
0
Avatar

Please help me with this calculation!!

Hi Podio community,

I have a small issue - I have been trying to create a table that will return a set of information with the first column being a hyperlink to the record.

I have the calculation to do this fine - HOWEVER, instead of returning text in the first column, I would prefer it to be a date, the date that record was created on, so have been using @createdon

Now, the table comes back with a load of undefined, and the hyperlink works but is not returning a date.

So 2 things, how to return the date in 12 Oct 2018 format AND get rid of all those undefined shenanigans.

here is my formula

var DateCreated= moment(@Created On).tz("Europe/London").format("DD MMM YYYY")
var URL= @All of Emergency contact URL;
var ContactName= @All of Name of your emergency contact;
var ContactRelationship= @All of What is their relationship to you?;
var ContactLocation= @All of Please state the city and country where your contact is based;
var lines = [];
for (var i=0; i < DateCreated.length; i++){
lines.push('[' +DateCreated[i]+ '](' +URL[i]+ ')' + " | " + ContactName[i] + " | " + ContactRelationship[i] + " | " + ContactLocation[i] )
};
if (lines != "") {
"Date Created | Contact Name | Relationship | Location \n" +
"--- | --- | --- | ---\n" +
lines.sort(DateCreated).join("\n");
} else {
"No Contact Created";
}

Here is the result

Thank you to anyone to responds!!!

Phi Tran

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Phi,

this: var DateCreated= moment(@Created On).tz("Europe/London").format("DD MMM YYYY")
is the creation date of the item where the calculation runs. And that is string. That doesn't make any sense.
What you want is the creation date of the wher you also get the contact name from. So in that app you have to add a field "Date Created", and then in the calculation you have to call it with
var DateCreated = @All of Date Created;
don't add moment().format at this point. 
Go on with: 

for (var i=0; i < DateCreated.length; i++){
lines.push('[' +moment(DateCreated[i]).tz("Europe/London").format("DD MMM YYYY") + '](' +URL[i]+ ')' + " | " + ContactName[i] + " | " + ContactRelationship[i] + " | " + ContactLocation[i] )
};
if (lines != "") { 
"Date Created | Contact Name | Relationship | Location \n" +
"--- | --- | --- | ---\n" +
lines.sort(DateCreated).join("\n"); 
} else {
"No Contact Created";
};

Rainer

Rainer Grabowski 0 votes
0
Avatar

Rainer - Always Rainer - Thank you.

I think we need to get you a white horse and some shining armour!

Phi Tran 0 votes