# Trigger a javascript function from a custom action in Glide

**URL:** https://community.glideapps.com/t/trigger-a-javascript-function-from-a-custom-action-in-glide/57660
**Category:** Ask for Help
**Created:** [February 8, 2023, 1:18pm UTC](https://community.glideapps.com/t/trigger-a-javascript-function-from-a-custom-action-in-glide/57660 "2023-02-08T13:18:27Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)
#### Post date: [March 4, 2023, 12:06pm UTC](https://community.glideapps.com/t/trigger-a-javascript-function-from-a-custom-action-in-glide/57660/8 "2023-03-04T12:06:58Z")

</div>

Sure,

Just create an additional conditional sentence (If - then) to control the execution code:

```auto
let myTrigger = p1; // p1 is the 1st parameter
if (myTrigger == True) {
    var data= await fetch('YOUR_URL', {
       method: 'POST',
        headers: {
           'Content-Type': 'application/x-www-form-urlencoded',
           'Authorization': 'YOUR_BearerToken'
        },
    });
    const json = await data.text(); // or data.json();   
    return json
  }

```

Now, you can create a custom action using the new [Wait Action feature](https://community.glideapps.com/t/wait-action/23794/54) to get it:

1. Set **True** to code’s trigger (“myTrigger” as parameter/column)
2. Wait 2-3 sec to allow the JS to run
3. Set **False** to code’s trigger to disable next executions

Saludos!

---

_[View the full topic](https://community.glideapps.com/t/trigger-a-javascript-function-from-a-custom-action-in-glide/57660)._
