OpenFn/lwala

If username is in a list of `testUsers`, then stop the job run and take no action in Salesforce

Closed this issue · 3 comments

Background

Lwala uses OpenFn integrate CommCare and Salesforce for its connected health system. Sometimes when training new CommCare clinic users, users will log into test CommCare accounts and upload dummy data, which causes the Salesforce integration to fail because related records do not exist in Salesforce. To avoid having several OpenFn runs fail during these training sessions, we'd like to implement logic into the OpenFn jobs so that no actions are logged in Salesforce when such test data is entered in CommCare.

We did something very similar for MiracleFeet: https://www.openfn.org/projects/lwala-chw-support/messages/061b070b-45ed-7399-8a7e-7b810e05d1ac

Request

If state.data.metadata.username contains one of these testUsers (see below), do NOT execute actions in Salesforce --> stop job run and log "This is a CommCare test user. Not uploading data to Salesforce."

const testUsers = [
  'test.2021',
  'test.2020',
  'test.202020'
];

state

See LP for Lwala Salesfoce Sandbox (MOTG - Implementation user)`.
https://www.openfn.org/projects/lwala-chw-support/messages/061b070b-45ed-7399-8a7e-7b810e05d1ac

expression

https://github.com/OpenFn/lwala/blob/master/commcare-salesforce-jobs/MOH514-Update-Person-in-SF-Production.js

adaptor

language-salesforce --> Use FakeAdaptor for local testing

output

Do not execute any actions in Salesforce if state contains a test CommCare username. Otherwise, proceed as normal (nothing should change about the existing job execution).

Re-try this run failure after making the changes (this should now be logged as a successful run, but with no actions executed in Salesforce): https://www.openfn.org/projects/lwala-chw-support/runs/061d2a46-5ac2-76f1-b22a-435b92e3d883

@grayey @lakhassane another issue to work on sometime this week, not urgent

thanks @grayey. Updated the consoloe.log message per my request in the issue, but otherwise looking good!