Modify setUser(c) function so that if
IF Oscar c.is_referred = true....
Keep the existing logic where we slice a location code and use this to set the Province User (see L349).
IF Oscar c.is_referred = false....
Build an agencyId by finding Oscar c.organization_name (i.e., "cif")...
Then append agency- to return agencyId string agency-${c.organization_name}
Use this agencyId (i.e., agency-cif) to look up the corresponding agency user in the agencyMap (see below)
If no agency found, throw error: "No agency user found for the organization ${organization_name}. Please create an agency user for this organization and update the job accordingly."
https://github.com/OpenFn/unicef-cambodia/blob/a5a8e2086ead6a890d2fa6c0fcb9a289e817c586/jobs/f2-j2-upsertCasesToPrimero.js#L426
Modify
setUser(c)
function so that if IF Oscarc.is_referred = true
.... Keep the existing logic where we slice a location code and use this to set the Province User (see L349).IF Oscar
c.is_referred = false
....c.organization_name
(i.e.,"cif"
)...agency-
to return agencyId stringagency-${c.organization_name}
agency-cif
) to look up the corresponding agency user in theagencyMap
(see below)"No agency user found for the organization ${organization_name}. Please create an agency user for this organization and update the job accordingly."