OpenFn / grassroot-soccer

Grassroot Soccer CommCare-Salesforce integrations
https://openfn.github.io/grassroot-soccer/
0 stars 0 forks source link

Update coach mapping logic #6

Closed aleksa-krolls closed 3 years ago

aleksa-krolls commented 3 years ago

Background

See issue #1 for original specs.

Request

An Event may have more than 1 Coaches ... it depends (Coach A, Coach B, etc.). If there is more than 1 Coach specified in state coaches, we need to map them to the relevant Salesforce field... Coach A = coach 1 Coach B = coach 2 Coach C = coach 3 Coach D = coach 4 If there is a coach 5 or more... don't map to the Event record. These Coach fields are a lookup field that relate Events to Persons in Salesforce and should follow the syntax... relationship('Coach_A__r', 'CommCare_Ext_ID__c',${coach2}) where coach2 would be the second coach reported in CommCare

I tried to implement this mapping here to pick out the different coaches from an array... but the problem is that if a coach is undefined, it causes the job to fail... but it's okay if Coach B, C, or D are not specified... some Events only have 1 Coach. https://github.com/OpenFn/grassroot-soccer/blob/5505ac0545b62da43addd4435eae7c035f8a2ac1/jobs/2.a.upsertInterventions.js#L39-L42

Please update my mapping so it will work with this state!

state

To replicate the issue... un-comment out my coach mappings on L40 and run against this message. https://www.openfn.org/projects/pd3yk4/messages/m78n66bp

expression

https://github.com/OpenFn/grassroot-soccer/blob/master/jobs/2.a.upsertInterventions.js

aleksa-krolls commented 3 years ago

@chaiwa-berian please also check this out today or Monday