Skip to main content

Q3 2022 Update HH Name in CommCare

This job was provided by an OpenFn.org user via the job library API.

Metadata

  • Name: Q3 2022 Update HH Name in CommCare
  • Adaptor: @openfn/language-commcare
  • Adaptor Version: v1.4.1
  • Created over 3 years ago
  • Updated about 2 months ago
  • Score: 0 (an indicator of how useful this job may be)

Key Functions

map, submitXls, Array

Expression

// Update CommCare case
fn(state => {
const { Notification } = state.data.Envelope.Body.notifications;

const Notifications = Array.isArray(Notification)
? Notification
: [Notification];

const notifications = Notifications.map(notification => {
console.log(
`Mapping HH code to CommCare: `,
notification.sObject.Household_Code_Autonumber__c
);
return {
case_id: notification.sObject.Commcare_Code__c,
name: notification.sObject.Household_Code_Autonumber__c,
};
});

return { ...state, notifications };
});

submitXls(state => state.notifications, {
case_type: 'Household',
search_field: 'case_id',
search_column: 'case_id',
name_column: 'name',
create_new_cases: 'off',
});