OpenFn / grassroot-soccer

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

If no `coach_name` in state, search for existing Coach via Event #22

Closed aleksa-krolls closed 3 years ago

aleksa-krolls commented 3 years ago

Request

We need to always link this Attendance record to a Coach, but sometimes coach_name is missing from state. https://github.com/OpenFn/grassroot-soccer/blob/6a94aa024ece0ba03f5980dd046fefbfc8b2f506/jobs/upsertCoachSessionRegister.js#L56

Please add logic so that if form.coach_name is not defined, then...

SELECT Coach_A__c from Event__c where CommCare_Case_ID__c = `${state.data.form.case.@case_id}`

Then return the value of Coach_A__c in this mapping on L56...

relationship('Person_Attendance__r', 'CommCare_Ext_ID__c', dataValue('coachA_id')),

state

See LP for GRS Salesforce Production https://www.openfn.org/projects/pd3yk4/messages/mwbaqb4d To test, please run this^ on prod.

expression

jobs/upsertCoachSessionRegister.js

lakhassane commented 3 years ago

@aleksa-krolls the coach_name is being set using the query you typed there. But seems like it does not exist in the lookup table: https://www.openfn.org/projects/pd3yk4/runs/rwaga4y4

aleksa-krolls commented 3 years ago

@lakhassane ok, so I tried to make one change... but then I reverted back to your latest version. Since you removed alterstate, I don't think this job is working. See latest run: https://www.openfn.org/projects/pd3yk4/runs/r3xjxpak

Then, please replace like L58 with the query returned value for Coach_A__r.CommCare_Ext_ID__c (not Coach_A__c). https://github.com/OpenFn/grassroot-soccer/blob/c92988dd04817732597f79dc82b7105a4285aa11/jobs/upsertCoachSessionRegister.js#L55-L59

lakhassane commented 3 years ago

@aleksa-krolls I made the change and re-run the job: https://www.openfn.org/projects/pd3yk4/runs/rj5ja4ex