OpenFn / grassroot-soccer

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

Map Risk & Vulnerability Assessment | Service Referral - Treatment, Care and Support form to Salesforce #17

Closed daissatou2 closed 3 years ago

daissatou2 commented 3 years ago

Background, context, and business value

The Risk & Vulnerability Assessment | Service Referral - Treatment, Care and Support form can upsert both the Risk_Assessment__c object and the NewReferral__c object depending on how it is filled out. Use the mapping sheet to create a job that upserts one or both objects.

The specific request, in as few words as possible

1 new job that may perform 1 or 2 operations...

  1. If form.do_you_want_to_perform_a_risk_assessment is in the message is yes then upsert Risk_Assessment__c using state.data.id as the unqiue identifier.

  2. If form.risk_assessment.drugs_and_alcohol_use.complete_service_referrals is yes && form.referral_services is present then upsert NewReferral__c using form.subcase_0.case.@caseid as the unique indentifier.

Please ignore the rows in yellow.

Use this other job https://www.openfn.org/projects/pd3yk4/jobs/jv4er4 as an example of how to upsert the NewReferral__c object.

state.json

Salesforce creds: See LP GRS Salesforce Sandbox CommCare creds: See LP GRS CommCare App

Upsert Risk_Assessment__c only: https://www.openfn.org/projects/pd3yk4/messages/m8qvpw3e Upsert New_Referral__c only: https://www.openfn.org/projects/pd3yk4/messages/mmq5rz7n Upsert both: https://www.openfn.org/projects/pd3yk4/messages/m664jnp8

adaptor

Salesforce

trigger

Form name : Risk & Vulnerability Assessment | Service Referral

expression.js

New job you can link to prod here: https://www.openfn.org/projects/pd3yk4/jobs/jvbbrp

aleksa-krolls commented 3 years ago

@chaiwa-berian @taylordowns2000 this is the second GRS issue to be worked on today. Let @daissatou2 know if you have any questions.

chaiwa-berian commented 3 years ago

@aleksa-krolls @daissatou2 This job is ready for testing. Kindly link it to a job in prod whenever you are ready to test. The biggest surprise is mapping the X4_0_Forms_of_abuse_experienced_before__c picklist. When you have a moment, tomorrow morning, @daissatou2 or @aleksa-krolls kindly let me know so I can have a quick look at the way the picklist looks in SF! Right now it is not clear how the values should be sent, so we are getting the error below: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST: 4.0 Forms of abuse experienced before: bad value for restricted picklist field: Sexual Physical Emotional Verbal Neglect

daissatou2 commented 3 years ago

Thanks Chaiwa! I've already let the client know to update the data type for X4_0_Forms_of_abuse_experienced_before__c to multi-select, so we'll wait for that and update the job as necessary.

daissatou2 commented 3 years ago

@chaiwa-berian @aleksa-krolls The job is passing for the message that upserts both NewReferral__c and Risk_Assessment__c.

However, it is failing for the messages where we're upserting only one of the objects (because the other object's fields are missing in the message). See runs below. The job should pass when we're upserting both objects AND when upserting just one.

Upsert New_Referral__c only: https://www.openfn.org/projects/pd3yk4/runs/rj5exyyz Upsert Risk_Assessment__c only: https://www.openfn.org/projects/pd3yk4/runs/rn5dm8bb

aleksa-krolls commented 3 years ago

@chaiwa-berian Can you please check out @daissatou2 feedback this morning? cc @taylordowns2000

chaiwa-berian commented 3 years ago

@aleksa-krolls @daissatou2 This is fixed here, but blocked by this PR. So you would wait until the PR language-salesforce is merged.

Cc: @taylordowns2000 @stuartc

daissatou2 commented 3 years ago

@chaiwa-berian The client has updated the type for X4_0_Forms_of_abuse_experienced_before__c from picklist to multi-select picklist.

Please resolve this error message: X4_0_Forms_of_abuse_experienced_before__c For multi-select picklist Salesforce expects the format value1; value2 (separated by ;)

chaiwa-berian commented 3 years ago

@aleksa-krolls @daissatou2 , This is fixed. I tested the three messages below and they all pass:

  1. https://www.openfn.org/projects/pd3yk4/runs/rrk3pa8m
  2. https://www.openfn.org/projects/pd3yk4/runs/rwapym98
  3. https://www.openfn.org/projects/pd3yk4/runs/raaw43xa