# Javascript - are some functionality not available

**URL:** https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067
**Category:** Ask for Help
**Created:** [December 28, 2023, 3:39pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067 "2023-12-28T15:39:11Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [December 28, 2023, 3:39pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/1 "2023-12-28T15:39:11Z")

</div>

I’m total javascript novice - so bear with me

I tried to convert from json to markdown (see post below)

I use the below code - but it seems as it wont run due to unknown forEach. When I have tried to use javascript in glide earlier on then I often cannot get the javascript to run.

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/f/5fc10856d5abfb8053ccf66aa3df063b8af38c91.png)

Anyway to fix this?

let markdownTable = “| Store | Title | Period |\n|-------|-------|--------|\n”;

```
p1.forEach(item => {
    let period = item.dateRange.replace("Present", "Now");
    markdownTable += `| ${item.storeName} | ${item.jobShort} | ${period} |\n`;
});

return markdownTable;

```

> [@Convert from JSON to markdown/html table](https://community.glideapps.com/t/convert-from-json-to-markdown-html-table/69064/2):
>
> Two ways I can think of to approach this: Use a JavaScript column to parse the JSON and output the HTML table. The dates would be a bit fiddly, but other than that it should be pretty straight forward. (ChatGPT would be able to help you). Use a series of Query JSON columns inside a Helper Table to pull the individual values, and then build the HTML with a Template and Joined List. Again, the dates would be a bit fiddly. Now that I’ve typed that out, I think I’d favour the first option wink

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [December 28, 2023, 3:45pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/2 "2023-12-28T15:45:51Z")

</div>

Is that the whole code?

Assuming that `p1` is your JSON string, then you need to parse it into an object first.  
Change your code as follows:

```auto
const json = JSON.parse(p1);
let markdownTable = “| Store | Title | Period |\n|-------|-------|--------|\n”;
json.forEach(item => {
    let period = item.dateRange.replace("Present", "Now");
    markdownTable += `| ${item.storeName} | ${item.jobShort} | ${period} |\n`;
});

return markdownTable;

```

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [December 28, 2023, 4:00pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/3 "2023-12-28T16:00:32Z")

</div>

@Krivo - I just noticed that there are “smart” quotes on line 2 (because I copied/pasted what you gave), which breaks the code.

Here is a working and tested version:

```auto
const json = JSON.parse(p1);
let markdownTable = `| Store | Title | Period |\n|-------|-------|--------|\n`;
json.forEach(item => {
    let period = item.dateRange.replace("Present", "Now");
    markdownTable += `| ${item.storeName} | ${item.jobShort} | ${period} |\n`;
});

return markdownTable; 

```

 ![CleanShot 2023-12-28 at 23.58.00@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/0/50749f590e82d7d1ae3c064ed7e0fee167b62bd5.png)

---

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [December 28, 2023, 4:01pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/4 "2023-12-28T16:01:09Z")

</div>

@Darren_Murphy Doesn’t seem to work ☹  
I have checked that the data in p1 is actually valid json ([Best JSON Viewer and JSON Beautifier Online](https://codebeautify.org/jsonviewer))

Any hints?

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/c/9c46596320766a27a955874fb74c4c28aa67108b.png)

The code I’m using (change to " instead of “)

```auto
const json = JSON.parse(p1);
let markdownTable = "| Store | Title | Period |\n|-------|-------|--------|\n";
json.forEach(item => {
    let period = item.dateRange.replace("Present", "Now");
    markdownTable += `| ${item.storeName} | ${item.jobShort} | ${period} |\n`;
});

return markdownTable;

return markdownTable;

```

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [December 28, 2023, 4:01pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/5 "2023-12-28T16:01:58Z")

</div>

See my previous reply ☝

---

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [December 28, 2023, 4:16pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/6 "2023-12-28T16:16:18Z")

</div>

@Darren_Murphy I keep repeting myself. You are a star ⭐ ⭐ ⭐ ⭐ ⭐

As side node.  
I used a “Query Json” as input to the javascript column - and even if looks as a valid JSON it is not.

I therefore used the “Query Json” column output as input in a template column - doing no manipulation with the input. The result was then valid JSON which the javascript accepted.

Should this be considered a bug?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [December 28, 2023, 4:40pm UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/7 "2023-12-28T16:40:05Z")

</div>

I don’t know this for a fact, but my guess would be as follows:

- the JavaScript column only accepts text as input
- your Query JSON column is returning a JSON object (not a JSON string), therefore it fails when you pass it to the JavaScript column
- passing it through a Template column converts the object to text.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [December 29, 2023, 12:18am UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/8 "2023-12-29T00:18:11Z")

</div>

> [@Krivo](#):
>
> I used a “Query Json” as input to the javascript column - and even if looks as a valid JSON it is not.

Check for any “keys” that might contain double quotes, the column will render your JSON but it doesn’t handle this error. You can run it through something like [https://jsonlint.com/](https://jsonlint.com/).

Always make sure you parse the JSON because it’s seen as text in the input phase like Darren wrote out.

```auto
const json = JSON.parse(p1);

```

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)
#### Post date: [January 5, 2024, 12:19am UTC](https://community.glideapps.com/t/javascript-are-some-functionality-not-available/69067/9 "2024-01-05T00:19:07Z")

</div>

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