This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upsert('Payment__c', 'EE_Payment_ID__c', fields( | |
field("EE_Payment_ID__c", state => { | |
const { msisdn, District, reference_number, house_number, contract_number, payment_number } = state.data; | |
const countryCode = (msisdn.substr(0,3) == "250" ? 'RW' : 'Msisdn code not found' ); | |
// ========================================================================= | |
// TODO: Aleksa discuss with TD. Why are you catching this error? | |
// What will happen when we send 'District code not found' downstream? | |
function findDistrictCode(district) { | |
const districtFind = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Jobs are evaluated as Javascript... | |
//Here we are named functions from the OpenFn Mailgun language-pack: https://github.com/openfn/language-mailgun | |
send( | |
fields( | |
field('from', 'sebastian@gmail.com'), | |
field('to', 'recipient2@email.com'), | |
field('subject', 'Kobo: New Form Submitted'), | |
//Using Javascipt, you can write your own custom, anonymous functions to do whatever you desire - see function(state) | |
//Below I use the OpenFn dataValue() function to create a message & dynamically fill in the recipient name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Jobs are evaluated as Javascript... | |
//Here we are named functions from the OpenFn Mailgun language-pack: https://github.com/openfn/language-mailgun | |
send( | |
fields( | |
field('from', 'sebastian@gmail.com'), | |
//You can send to multiple email addresses by separating with a comma | |
field('to', 'sebastian@gmail.com, recipient2@email.com'), | |
field('subject', 'Kobo: New Form Submitted'), | |
field('text', 'Log into Kobo to review the new form submitted.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
field('Name', (state) => { | |
return state.data.properties.patient_name + "(" + | |
state.data.properties.patient_id + ") (" + | |
state.data.properties.date_opened + ")" | |
//I used date_opened because i didn't see a visit_date property in the message body data | |
//you will want to confirm that this is the right date field to user | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alterState((state) => { | |
state.handlePhoto = function handlePhoto(state, photoField) { | |
const url1 = `https:` | |
const url2 = `/` | |
const baseUrl = `/www.commcarehq.org/a/${state.data.domain}/api/form/attachment/`; | |
const uuid = state.data.metadata.instanceID; | |
const image = (state.data.form.photos ? state.data.form.photos[`${photoField}`] : null); | |
return ( image ? `${url1}${url2}${baseUrl}${uuid}/${image}` : "" ) | |
}; | |
//************ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
field('gciclubfoot__Brace_Count__c', dataValue('form.subcase_0.case.update.brace_count')), | |
//in below line, try changing humanProper() to datavalue() --> this is line 34 in the job | |
field('gciclubfoot__Brace_Problems__c', humanProper('form.subcase_0.case.update.brace_problems')), // picklist | |
field('gciclubfoot__Brace_Problems_Notes__c', dataValue('form.subcase_0.case.update.brace_problems_specified')), | |
field('gciclubfoot__Brace_Problems_Type__c', (state) => { | |
return state.handleMultiSelect(state, "brace_problems_type") | |
}), | |
field('gciclubfoot__Brace_Type__c', (state) => { | |
const ref = state.data.form.subcase_0.case.update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
field('Bracing_Stage__c', dataValue('properties.bracing_stage')), | |
/* (<-- add this to comment out a set of lines) | |
field('gciclubfoot__Diagnosis_Idiopathic_Specified__c', (state) => { | |
return state.handleMultiSelect(state, "diagnosis_idiopathic_specified") | |
}), | |
field('gciclubfoot__Diagnosis_Secondary_Specified__c', (state) => { | |
return state.handleMultiSelect(state, "diagnosis_secondary_specified") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"trackedEntity": "UgB6oOE7jYb", | |
"orgUnit": "dVtKvuWFMaP", | |
"attributes": [ | |
{ | |
"attribute": "kKbVP14xj1A", | |
"value": "A35789235" | |
}, | |
{ | |
"attribute": "mrRDbHRkOSV", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"trackedEntityType": "UgB6oOE7jYb", | |
"orgUnit": "dVtKvuWFMaP", | |
"attributes": [ | |
{ | |
"attribute": "kKbVP14xj1A", | |
"value": "A357892346" | |
}, | |
{ | |
"attribute": "mrRDbHRkOSV", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"trackedEntityType": "MCPQUTHX1Ze", | |
"orgUnit": "nKdtlnZztYd", | |
"attributes": [ | |
{ | |
"attribute": "TLjYqcKwhxP", | |
"value": "Alison Newbie" | |
}, | |
{ | |
"attribute": "ScSWoiqvdp5", |
OlderNewer