# Job Writing

**URL:** https://community.openfn.org/c/jobs/5.md

[Latest](https://community.openfn.org/latest.md) · [Categories](https://community.openfn.org/categories.md)

---

## [About the Job Writing category](https://community.openfn.org/t/about-the-job-writing-category/11)

<div class="topic-metadata">

**Author:** [@system](https://community.openfn.org/u/system)\
**Replies:** 0\
**Last updated:** [September 1, 2020, 1:23pm UTC](https://community.openfn.org/t/about-the-job-writing-category/11 "2020-09-01T13:23:28Z")

</div>

Ask and answer questions related to OpenFn job expressions here. Remember that including a code and log snippet in your topics usually leads to a faster resolution. And.. if (sharingCode) { console.log("Please format …

---

## [Just wrapped up my OpenFn email automation workflow!](https://community.openfn.org/t/just-wrapped-up-my-openfn-email-automation-workflow/996)

<div class="topic-metadata">

**Author:** [@cent](https://community.openfn.org/u/cent)\
**Replies:** 4\
**Last updated:** [June 30, 2025, 12:03pm UTC](https://community.openfn.org/t/just-wrapped-up-my-openfn-email-automation-workflow/996 "2025-06-30T12:03:19Z")

</div>

After 5+ hours of testing and refining, I got it working, fetching unread Gmail messages, extracting key info, and logging everything neatly into Google Sheets. :wrench: Fixes & Wins: Handled .map() on undefined by…

---

## [Issue with each](https://community.openfn.org/t/issue-with-each/964)

<div class="topic-metadata">

**Author:** [@delcroip](https://community.openfn.org/u/delcroip)\
**Replies:** 6\
**Last updated:** [May 28, 2025, 1:40pm UTC](https://community.openfn.org/t/issue-with-each/964 "2025-05-28T13:40:34Z")

</div>

Dear, I am trying to load some mapping from OCL into collection but I cannot manage to get it working here my job // Check out the Job Writing Guide for help getting started: // https://docs.openfn.org/documentation/j…

---

## [ReferenceError: collections is not defined](https://community.openfn.org/t/referenceerror-collections-is-not-defined/960)

<div class="topic-metadata">

**Author:** [@delcroip](https://community.openfn.org/u/delcroip)\
**Replies:** 5\
**Last updated:** [May 26, 2025, 1:59pm UTC](https://community.openfn.org/t/referenceerror-collections-is-not-defined/960 "2025-05-26T13:59:15Z")

</div>

dear all I was really happy to finally test collections but on the latest docker 2.12.2 I am getting that message R/T Error occurred at: get data from OCL R/T 24: collections.remove('global-almanach-dhis2', { created…

---

## [Help wanted! I'd love to hear your feedback on namespaces in job writing!](https://community.openfn.org/t/help-wanted-id-love-to-hear-your-feedback-on-namespaces-in-job-writing/952)

<div class="topic-metadata">

**Author:** [@joe](https://community.openfn.org/u/joe)\
**Replies:** 3\
**Last updated:** [May 8, 2025, 4:25pm UTC](https://community.openfn.org/t/help-wanted-id-love-to-hear-your-feedback-on-namespaces-in-job-writing/952 "2025-05-08T16:25:45Z")

</div>

Hi Community - I need your help! I am trying to decide whether namespaces in adaptors - like http.get() or util.uuid() - are useful when reading or writing job code. I’m going to post the question first, and then give …

---

## [Post Request to API](https://community.openfn.org/t/post-request-to-api/904)

<div class="topic-metadata">

**Author:** [@Kiefer](https://community.openfn.org/u/Kiefer)\
**Replies:** 3\
**Last updated:** [March 21, 2025, 4:23pm UTC](https://community.openfn.org/t/post-request-to-api/904 "2025-03-21T16:23:48Z")

</div>

I am currently attempting a simple post request for testing purposes to an API endpoint. Using lightning V2.10.15 running locally. For reference: This Post request was working couple weeks ago, but API got updated a…

---

## [Kobo \`getSubmissions()\` results in ERR\_BAD\_REQUEST](https://community.openfn.org/t/kobo-getsubmissions-results-in-err-bad-request/776)

<div class="topic-metadata">

**Author:** [@stephencoduor](https://community.openfn.org/u/stephencoduor)\
**Replies:** 10\
**Last updated:** [March 13, 2025, 2:40pm UTC](https://community.openfn.org/t/kobo-getsubmissions-results-in-err-bad-request/776 "2025-03-13T14:40:59Z")

</div>

Hello Community, I have just spin up lightning instance, I have a workflow using kobotoolbox to version 2.4.3 in one of the steps (Fetching submissions) I can’t figure why I am getting error on my run, I have tried s…

---

## [New OpenFn VSCode support 🚀](https://community.openfn.org/t/new-openfn-vscode-support/881)

<div class="topic-metadata">

**Author:** [@farhan](https://community.openfn.org/u/farhan)\
**Replies:** 1\
**Last updated:** [March 10, 2025, 10:03am UTC](https://community.openfn.org/t/new-openfn-vscode-support/881 "2025-03-10T10:03:45Z")

</div>

Hey community! Farhan here from the core dev team. I wanna share with you the new VS Code extension, which will let you write OpenFN workflows directly from VS Code Here’s a short video to show you how it works An ove…

---

## [Storing API Post Response](https://community.openfn.org/t/storing-api-post-response/869)

<div class="topic-metadata">

**Author:** [@Kiefer](https://community.openfn.org/u/Kiefer)\
**Replies:** 1\
**Last updated:** [February 27, 2025, 3:09pm UTC](https://community.openfn.org/t/storing-api-post-response/869 "2025-02-27T15:09:17Z")

</div>

I am currenlty working on a job using Lightining V2.10.15 where I am creating multiple Post requests to Odoo. I can successfully post to the Odoo instance but i would like to store the response from the each post reqeust…

---

## [Optimizing Processing Time for Payment Tracking and Database Handling](https://community.openfn.org/t/optimizing-processing-time-for-payment-tracking-and-database-handling/826)

<div class="topic-metadata">

**Author:** [@FilmonK](https://community.openfn.org/u/FilmonK)\
**Replies:** 6\
**Last updated:** [February 5, 2025, 1:27pm UTC](https://community.openfn.org/t/optimizing-processing-time-for-payment-tracking-and-database-handling/826 "2025-02-05T13:27:33Z")

</div>

Hello OpenFn Community, This is philmon from MedcoAnalytics Technology Solutions. We are experiencing processing time issues when tracking payments and handling data in our database, which is impacting efficiency, espec…

---

## [Fetching data from CommCare to PostgreSQL with OpenFn](https://community.openfn.org/t/fetching-data-from-commcare-to-postgresql-with-openfn/825)

<div class="topic-metadata">

**Author:** [@ayodele](https://community.openfn.org/u/ayodele)\
**Replies:** 0\
**Last updated:** [February 4, 2025, 1:13pm UTC](https://community.openfn.org/t/fetching-data-from-commcare-to-postgresql-with-openfn/825 "2025-02-04T13:13:03Z")

</div>

Earlier today, @Meghan-Gilroy shared this amazing article from @SimonKihara on their experience using OpenFn to build a workflow that fetches data from CommCare, transforms the data, and pushes the output to a PostgreSQL…

---

## [Fields not updating during insert](https://community.openfn.org/t/fields-not-updating-during-insert/628)

<div class="topic-metadata">

**Author:** [@djohnson](https://community.openfn.org/u/djohnson)\
**Replies:** 19\
**Last updated:** [January 24, 2025, 6:51am UTC](https://community.openfn.org/t/fields-not-updating-during-insert/628 "2025-01-24T06:51:39Z")

</div>

Hi all, when trying to insert records using the Salesforce adaptor version 4.6.2, there are some fields that are not updated despite being in the final JSON before the insert. There is also no error message that indicate…

---

## [Error reporting improvements](https://community.openfn.org/t/error-reporting-improvements/793)

<div class="topic-metadata">

**Author:** [@joe](https://community.openfn.org/u/joe)\
**Replies:** 0\
**Last updated:** [January 21, 2025, 10:46am UTC](https://community.openfn.org/t/error-reporting-improvements/793 "2025-01-21T10:46:47Z")

</div>

Hi folks, I wanted to post a little update about a big new feature in the core runtime: source positions in errors!! This affects the Worker 1.9.0 (live on app right now and bundled with Lightning 2.10.10) and CLI 1…

---

## [Live online demo: Data Collections](https://community.openfn.org/t/live-online-demo-data-collections/671)

<div class="topic-metadata">

**Author:** [@ayodele](https://community.openfn.org/u/ayodele)\
**Replies:** 4\
**Last updated:** [December 13, 2024, 10:40am UTC](https://community.openfn.org/t/live-online-demo-data-collections/671 "2024-12-13T10:40:36Z")

</div>

​Like @Kiefer, have you ever wished for a way to store and reuse data across all your workflows? If Yes, then you should learn about data collections. We released data collections as a new feature in v2.10.0 as a secure…

---

## [Oddities using new collections feature when passing state value](https://community.openfn.org/t/oddities-using-new-collections-feature-when-passing-state-value/729)

<div class="topic-metadata">

**Author:** [@decarteret](https://community.openfn.org/u/decarteret)\
**Replies:** 3\
**Last updated:** [December 5, 2024, 8:37pm UTC](https://community.openfn.org/t/oddities-using-new-collections-feature-when-passing-state-value/729 "2024-12-05T20:37:38Z")

</div>

Loving the new collections feature! I’m having a bit of a problem figuring out the correct way to accomplish my goal: Adding to the state: fn((state) =\> { state.newItems = \["one", "two", "three"\]; console.log(state…

---

## [Using data from previous workflow run during it's second iteration](https://community.openfn.org/t/using-data-from-previous-workflow-run-during-its-second-iteration/665)

<div class="topic-metadata">

**Author:** [@Kiefer](https://community.openfn.org/u/Kiefer)\
**Replies:** 11\
**Last updated:** [December 3, 2024, 6:57pm UTC](https://community.openfn.org/t/using-data-from-previous-workflow-run-during-its-second-iteration/665 "2024-12-03T18:57:39Z")

</div>

What is the most effective way to implement this workflow in , where: Job 1 makes an API call to retrieve data on the first iteration. Job 2 pushes the data to another application via API. On subsequent iterations, Job…

---

## [What is State in OpenFn?](https://community.openfn.org/t/what-is-state-in-openfn/663)

<div class="topic-metadata">

**Author:** [@ayodele](https://community.openfn.org/u/ayodele)\
**Replies:** 2\
**Last updated:** [November 26, 2024, 10:35am UTC](https://community.openfn.org/t/what-is-state-in-openfn/663 "2024-11-26T10:35:14Z")

</div>

One of OpenFn’s frequently used terminologies is state and if you’re new to the OpenFn, you might wonder what it means. In our docs, we defined state as a javascript object that provides a means for the jobs to share inf…

---

## [Discourse webhook to Slack](https://community.openfn.org/t/discourse-webhook-to-slack/424)

<div class="topic-metadata">

**Author:** [@taylordowns2000](https://community.openfn.org/u/taylordowns2000)\
**Replies:** 1\
**Last updated:** [August 23, 2024, 5:22pm UTC](https://community.openfn.org/t/discourse-webhook-to-slack/424 "2024-08-23T17:22:16Z")

</div>

At OpenFn we wanted to get alerts on Slack whenever new posts came into this forum. Thanks to discourse’s “API → Webhook” feature it took me 2-minutes to automate. Thanks, Discourse, for being awesome. Here’s my OpenFn …

---

## [News: Introducing Promises & Phasing Out Callbacks](https://community.openfn.org/t/news-introducing-promises-phasing-out-callbacks/470)

<div class="topic-metadata">

**Author:** [@joe](https://community.openfn.org/u/joe)\
**Replies:** 0\
**Last updated:** [July 31, 2024, 9:59am UTC](https://community.openfn.org/t/news-introducing-promises-phasing-out-callbacks/470 "2024-07-31T09:59:29Z")

</div>

Hi community! Not to be too dramatic or anything but we recently a small feature which could change the face of adaptors forever. That new feature is quite simple really: Operations (top level function calls) now behav…

---

## [DHIS2 Error Handling](https://community.openfn.org/t/dhis2-error-handling/466)

<div class="topic-metadata">

**Author:** [@DanglebenC](https://community.openfn.org/u/DanglebenC)\
**Replies:** 4\
**Last updated:** [July 23, 2024, 12:31pm UTC](https://community.openfn.org/t/dhis2-error-handling/466 "2024-07-23T12:31:08Z")

</div>

Hi everyone, We are trying to implement error handling to continue importing dhis2 in the event that there may be a a duplicate individual within a different program. Currently, if there is a duplicate the job stops com…

---

## [Accessing subarrays with each operation](https://community.openfn.org/t/accessing-subarrays-with-each-operation/443)

<div class="topic-metadata">

**Author:** [@DanglebenC](https://community.openfn.org/u/DanglebenC)\
**Replies:** 1\
**Last updated:** [May 24, 2024, 6:22am UTC](https://community.openfn.org/t/accessing-subarrays-with-each-operation/443 "2024-05-24T06:22:41Z")

</div>

Hi everyone, What would be the best approach to access a sub array using the each operation in a job to push to DHIS2. Below is an example of the input used with all patient identifiable information removed. { "mer…

---

## [Run Complete with status:Crash](https://community.openfn.org/t/run-complete-with-status-crash/437)

<div class="topic-metadata">

**Author:** [@Kiefer](https://community.openfn.org/u/Kiefer)\
**Replies:** 4\
**Last updated:** [May 10, 2024, 2:55pm UTC](https://community.openfn.org/t/run-complete-with-status-crash/437 "2024-05-10T14:55:05Z")

</div>

Good Day, While running my workflow i suddenly got this error. This job was working previously and i made no changes to the code. However after creating a new workflow with the same code it works fine. I am running…

---

## [Pagination Function](https://community.openfn.org/t/pagination-function/436)

<div class="topic-metadata">

**Author:** [@DanglebenC](https://community.openfn.org/u/DanglebenC)\
**Replies:** 6\
**Last updated:** [May 9, 2024, 2:30pm UTC](https://community.openfn.org/t/pagination-function/436 "2024-05-09T14:30:55Z")

</div>

Hi All, Would it be possible to have an SQL get statement within a function? I am currently attempting to create a function to continuously offset and limit 10,000 records from an SQL database however I am having issues…

---

## [Bearer tokens with the HTTP adaptor](https://community.openfn.org/t/bearer-tokens-with-the-http-adaptor/435)

<div class="topic-metadata">

**Author:** [@bensonmiller](https://community.openfn.org/u/bensonmiller)\
**Replies:** 4\
**Last updated:** [May 7, 2024, 5:18pm UTC](https://community.openfn.org/t/bearer-tokens-with-the-http-adaptor/435 "2024-05-07T17:18:05Z")

</div>

Hello all - I’m having trouble using Bearer tokens with the HTTP adaptor on OpenFn 2.4.2. Specifically, the HTTP adaptor seems to be overwriting the Authorization header, even when I set the header’s value explicitly. T…

---

## [Write better jobs with the Lazy State Operator](https://community.openfn.org/t/write-better-jobs-with-the-lazy-state-operator/432)

<div class="topic-metadata">

**Author:** [@joe](https://community.openfn.org/u/joe)\
**Replies:** 0\
**Last updated:** [April 26, 2024, 9:21am UTC](https://community.openfn.org/t/write-better-jobs-with-the-lazy-state-operator/432 "2024-04-26T09:21:09Z")

</div>

Hi Community! I’m really excited to share a shiny new thing with you: The Lazy State Operator! get($.data.url) In a nutshell, the Lazy State Operator ($) provides an easier, neater way to reference properties on state…

---

## [New job writing guide!](https://community.openfn.org/t/new-job-writing-guide/423)

<div class="topic-metadata">

**Author:** [@joe](https://community.openfn.org/u/joe)\
**Replies:** 0\
**Last updated:** [April 2, 2024, 9:54am UTC](https://community.openfn.org/t/new-job-writing-guide/423 "2024-04-02T09:54:22Z")

</div>

Hi Community! We’ve just posted a brand new Job Writing Guide on our docs page. Like all documentation it’s a bit of a work in progress - but we hope that this will make it easier to get started writing jobs and explai…

---

## [Pulling data from Kobotoolbox form and insert them into DHIS2](https://community.openfn.org/t/pulling-data-from-kobotoolbox-form-and-insert-them-into-dhis2/419)

<div class="topic-metadata">

**Author:** [@mbebana](https://community.openfn.org/u/mbebana)\
**Replies:** 19\
**Last updated:** [March 29, 2024, 8:40am UTC](https://community.openfn.org/t/pulling-data-from-kobotoolbox-form-and-insert-them-into-dhis2/419 "2024-03-29T08:40:02Z")

</div>

Hi Community, I created job to extract data from Kobotoolbox form with GetSubmissions function. Data which is extracted from kobotoolbox should be inserted into DHIS2 dataset. When data gets extracted from Kobotoolbox,…

---

## [Access to request header](https://community.openfn.org/t/access-to-request-header/367)

<div class="topic-metadata">

**Author:** [@delcroip](https://community.openfn.org/u/delcroip)\
**Replies:** 13\
**Last updated:** [January 26, 2024, 8:58am UTC](https://community.openfn.org/t/access-to-request-header/367 "2024-01-26T08:58:37Z")

</div>

Dear all, openFn make it easy to access the body of the request, is there anyway to access the header ? (I am getting the username of the submitter in the header, I’d like to use it ) thanks in advance

---

## [Failed Runs from Commcare](https://community.openfn.org/t/failed-runs-from-commcare/376)

<div class="topic-metadata">

**Author:** [@Maluba\_M](https://community.openfn.org/u/Maluba_M)\
**Replies:** 1\
**Last updated:** [November 15, 2023, 11:36am UTC](https://community.openfn.org/t/failed-runs-from-commcare/376 "2023-11-15T11:36:29Z")

</div>

I have observed unsuccessful Runs from a GCR Skillz Malaria intervention with an error message ERROR\_HTTP\_400: Bad Request. Kindly refer to these OpenFn Links https://www.openfn.org/projects/grs-integrations/runs/06553…

---

## [Salesforce Upsert Statement](https://community.openfn.org/t/salesforce-upsert-statement/326)

<div class="topic-metadata">

**Author:** [@bryceVeraSolutions](https://community.openfn.org/u/bryceVeraSolutions)\
**Replies:** 8\
**Last updated:** [June 27, 2023, 8:14am UTC](https://community.openfn.org/t/salesforce-upsert-statement/326 "2023-06-27T08:14:05Z")

</div>

We are struggling to get our upsert statement for the Salesforce adapter to work. Does anything look wrong? How will we know if the records have successfully upserted? I understand in the openfn.org UI, SF will send back…

[Next page](https://community.openfn.org/c/jobs/5.md?page=1)
