# Starting a Task by Javascript

**URL:** <https://forums.knack.com/t/starting-a-task-by-javascript/13552>\
**Category:** Ask Developers\
**Created:** [December 21, 2022, 11:47pm UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552 "2022-12-21T23:47:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [December 21, 2022, 11:47pm UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/1 "2022-12-21T23:47:55Z")

</div>

Does anyone know if it’s possible to start an Object’s task programmatically using Javascript?  
Currently, only scheduled options are available but I need to do it on specific event, not cyclic period.

I dug deep into the Knack object and found task-related stuff but not sure how to use them.

Normand D.

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [December 22, 2022, 7:10am UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/2 "2022-12-22T07:10:46Z")

</div>

Hello Normand,

Yes, you can do that but it explores your api keys.

Regards,  
Sunny Singla

---

<div class="post-metadata">

**Author:** ![BradStevens](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/bradstevens/32/140_2.png) [@BradStevens](https://forums.knack.com/u/BradStevens)\
**Post date:** [December 22, 2022, 10:38pm UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/3 "2022-12-22T22:38:19Z")

</div>

Hey @Sunny_Singla keen to know the basic syntax if you can share something?

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [December 23, 2022, 2:26am UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/4 "2022-12-23T02:26:23Z")

</div>

Sure Brad,

try the below code it works for me.

$.ajax({  
url: ‘[https://eu-central-1-renderer-read.knack.com/v1/applications/\*\*APPLICATIONID\*\*/tasks/task\_1/runtaskjob](https://eu-central-1-renderer-read.knack.com/v1/applications/ **APPLICATIONID** /tasks/task_1/runtaskjob)’,  
type: ‘GET’,  
headers: {  
‘X-Knack-Application-Id’: ‘APPID’, // change to your app’s API info  
‘X-Knack-REST-API-Key’: ‘KEY’. // change to your app’s key  
},  
success: function (response) {

```
    }
});

```

you need to change task\_1 with you task id

Thanks

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [December 23, 2022, 4:03am UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/5 "2022-12-23T04:03:14Z")

</div>

Sunny,

That’s pretty cool, thanks!

I’m very curious to know… where did you get that information?  
Is there a full documentation of these functions somewhere?

Norm

---

<div class="post-metadata">

**Author:** ![BradStevens](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/bradstevens/32/140_2.png) [@BradStevens](https://forums.knack.com/u/BradStevens)\
**Post date:** [December 23, 2022, 5:58am UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/6 "2022-12-23T05:58:10Z")

</div>

Yep - same questions!  
Tested and works BTW and could be obfuscated via a [Make.com](http://Make.com) scenario.

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [December 23, 2022, 12:40pm UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/7 "2022-12-23T12:40:37Z")

</div>

Hello Normand,

There is no documentation for this.

Regards,  
Sunny Singla

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [December 23, 2022, 1:23pm UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/8 "2022-12-23T13:23:44Z")

</div>

Ok but then, how did you find out about the URL and the **runtaskjob** command?  
I wonder what else is hiding that could be useful…

Norm

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [December 23, 2022, 2:12pm UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/9 "2022-12-23T14:12:13Z")

</div>

I partially answered myself.

In the console view, I had an error on a PUT and saw this URL:  
[https://us-east-1-renderer-write.knack.com/v1/scenes/scene\_xxx/views/view\_yyy/records/](https://us-east-1-renderer-write.knack.com/v1/scenes/scene_xxx/views/view_yyy/records/)…

So I extracted the first part until the v1/ and tried this:  
[https://us-east-1-renderer-read.knack.com/v1/applications/APP\_ID](https://us-east-1-renderer-read.knack.com/v1/applications/APP_ID)

Tadam! A ton of code appeared, and at the end, there were my server URLs:

```auto
    "clientSubdomainMap": {
      "read": [
        "us-east-1-renderer-read"
      ],
      "write": [
        "us-east-1-renderer-write"
      ]
    }

```

But that’s only a partial answer. What about the **runtaskjob** command?

Norm

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [December 25, 2022, 4:52am UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/10 "2022-12-25T04:52:36Z")

</div>

Normand,

I also check this in the console. while running tasks manually.

Thanks,  
Sunny

---

<div class="post-metadata">

**Author:** ![Yee\_Hong](https://avatars.discourse-cdn.com/v4/letter/y/7feea3/32.png) [@Yee\_Hong](https://forums.knack.com/u/Yee_Hong)\
**Post date:** [June 26, 2024, 4:24pm UTC](https://forums.knack.com/t/starting-a-task-by-javascript/13552/11 "2024-06-26T16:24:38Z")

</div>

Hi, I am very new to the use of API and Javascript in general, but I am struggling with the same issue and this solution would be a fix for that. Are there any details you could provide on how to use [make.com](http://make.com) and the knack platform in order to trigger a task update with an update in records detected from [make.com](http://make.com)

Thank you!
