Closed daissatou2 closed 2 years ago
@daissatou2 I made the change but it is failing for the same reason: https://www.openfn.org/projects/pd3yk4/runs/r3xky693
Are those valid values for SF?
@chaiwa-berian we might need your input on something you worked on months ago :D
I'm seeing your function checked here https://github.com/OpenFn/grassroot-soccer/blob/master/jobs/upsertRiskVulnerabilityNewReferrals.js#L3-L6
Do you remember where key
in that function is from. Here is an example of how that function is used in the code:
https://github.com/OpenFn/grassroot-soccer/blob/master/jobs/upsertRiskVulnerabilityNewReferrals.js#L304-L309
@lakhassane The keys
were from the sample data
that @daissatou2 had shared with me. But here is how it works:
If the data coming from CommCare
is space separated
and their corresponding fields in Salesforce
are Checkboxes
like:
{"check_the_services_that_client_was_referred_to": "value1 value2 value3"}
values
in Salesforce
is a Checkbox
field, so we will map the values(value1, value2, etc) to individual corresponding Checkboxes
in Salesforce like below.Salesforce
field(as specified by @daissatou2 ) we lookup its corresponding value
in the CommCare
data. So the value
we are looking for will act as a key
, and if found then we know this Salesforce checkbox
is checked or ticked
. Again you have to confirm with @daissatou2 to give you the exact mappings(CommCare to Salesforce). The mappings looked something like value1 => ART_Initiation_GRS_Staff__c, value2 => Salesforce_Field_B, etc
checked
helper function would then be passed, value1
, for example, and the data from CommCare
(in this case dataValue("check_the_services_that_client_was_referred_to")
) then it will return false
or true
, for ART_Initiation_GRS_Staff__c
.Salesforce
receives a true
value for Checkbox
, it will mark/check/tick
the ART_Initiation_GRS_Staff__c
field or otherwise.check_the_services_that_client_was_referred_to
from CommCare
, converting the value
to boolean
and then map to a corresponding field in Salesforce
.Again, once you confirm with @daissatou2 the mappings and share what you are trying to achieve, then we can figure out whether we need to use checked
or some other helper transform
! Thanks.
Thanks Chaiwa! CommCare is sending all the options that were selected for a multi-picklist question in one field and separating them by spaces. We have to parse that, splitting on the space, and then check/tick each separate answer choice from the state in Salesforce. So for the message above, we need to tick both Physical
& Emotional
in Salesforce.
@lakhassane looks like we have docs on this: https://docs.openfn.org/documentation/apps/salesforce/#picklist-fields
@daissatou2 green check right away :D https://www.openfn.org/projects/pd3yk4/runs/rwax5mkx
@chaiwa-berian great thanks for your help here
Describe the bug
This job is currently failing when multiple options are chosen for the
form.risk_assessment.gender_based_violence.abuse_experienced
field in state. Because this is a multi-picklist field, when multiple options are chosen in CommCare, the options are separated by a space in state. For example, in this state,form.risk_assessment.gender_based_violence.abuse_experienced
equalsphysical emotional
. The run is failing because instead of selecting bothPhysical
&Emotional
in Salesforce, it is attempting to selectPhysical emotional
which doesn't exist.Please update the job to separate the options in this field by space.
To Reproduce
expression.js
Link to the job itself in Github: https://github.com/OpenFn/grassroot-soccer/blob/master/jobs/upsertRiskVulnerabilityNewReferrals.js
state.json
https://www.openfn.org/projects/pd3yk4/messages/mdbkjvwv
To test/resolve