Use cases for javascript column?

Hi everyone ! :wave:
I’m curious about the javascript column (or code column) in Glide data editor.

What are the possible use cases for this type of column ? :thinking:

Thank you !

There is a time, not that long ago, maybe October/November 2021, when the computed columns below “Construct URL” were not available. In fact, all of those as well as “Experimental code”, “Joined list”, “Split text” and “Make array” are quite recent.

Of these, “Experimental code” and “JS column” (one of the two was formally called “Yes-Code” if I recall correctly) were the first to be released, maybe around August/September last year. I get the two confused. One of these allowed Glide developers to code their own computed columns by hosting the code elsewhere and pulling in the code to Glide Tables. The new computed columns are use cases (all the ones below “Construct URL”).

I’m not answering your question but I’m giving you a little bit of context as to how these code columns came about. I hope that others that have a better understanding of these two columns might be able to chime in and actually give you use cases.

1 Like

Like @nathanaelb mentioned, the JavaScript column let’s you code your own computed column. You can pass in a few parameters (values from other columns), and perform complex calculations that return a value. It’s like a math column on steroids. People have used it for a variety of reasons, like to manipulate dates, work with arrays of data, perform really complex math, or really anything where you want to pass in some parameters, have it run through some code, and have it spit out a value.

I’ve used it to triangulate a geo location from three sets of coordinates. I’ve used it to calculate a compass bearing between two sets of coordinates. I’ve used it to convert regular text to text with a strike through style. The sky is pretty much the limit.

4 Likes

I mainly use the JavaScript column to manipulate data and as @nathanaelb mentioned the Yes-Code column, this is just a renamed version of it.

This has saved me a lot of columns, especially in cases where I have to return a value based on complex conditions.

Example:

If (p1 == “A” && p2 == “B”) {
return “One”;
}

if (p1 == “B” && p2 == “C”) {
return “Two”;
}

if (p1 == “C” || p3 == “A”) {
return “Three”;
}

else return “Four”;

That could have been a combination of a template column and an ITE column to return the right value. I have used JS for more complex cases than that.

3 Likes

Hola!

here another example to use Javascript plugin if you want to save columns or Glide’s tools (no code) are not enought to get a valid/easy solution.

2 Likes

Thanks for the answer !

1 Like

Thank you ! Perfectly clear !

2 Likes

If there’s something I want to be improved specifically for that column, it’s the ability to pass in more inputs.

However we can have a workaround of combining as many variables as needed in a template beforehand, with a separator (let’s say comma) between them. Then when you start writing the code, split the template into an array and access variables by their index.

1 Like

Yeah, I’ve used the split trick to pass in a lot more than 3 parameters.

2 Likes

but I would still like to have at least 5 parameters! :joy:

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.