Description
Background, context, and business value
Grassroot Soccer is rebuilding their integration, previously flowing from CommCare → Salesforce. The destination system is transitioning from a custom Salesforce data model to Amp Impact, which is a standardized data model built on Salesforce. The source system (CommCare) remains unchanged.
This update focuses on remapping existing workflows to align with the new Amp Impact data model, guided by updated mapping specifications. Much of the transformation logic in the previous implementation will be reused; however, Salesforce object and field targets will differ.
This issue relates specifically to the Upsert Risk and Vulnerability Assessment - Service Referral workflow, which needs to be rebuilt to match the updated mapping specification.
The specific request, in as few words as possible
- Update the exisiting code here with the updated mapping spec
Steps:
This workflow is creating two types of records for a single form from CommCare:
- Risk Assessment records - When a risk assessment is performed (based on the value of "state.data.perform_a_risk_assessment")
Note: this issue has an already existing code for this section: Remap Upsert Pre/post Challeges #70
- This workflow will first fetch ampi__Submission__c using the following query:
query(`
SELECT Id, Name, RecordTypeId, ampi__Description__c, Type__c, Active__c, Curriculum__r.Name
FROM ampi__Submission__c
WHERE Active__c = true
AND RecordType = Submission
AND Type__c = 'Risk Assessment'
`);
- Next it will query an
ampi__Project__c
whereName = state.data.form.client_information.intervention_name
and save the returned object id as the event id - Next it will create an
ampi__Submission__c
as per the mapping spec - Next it will fetch the
ampi__Question__c
for theampi__Submission__c
created in the previous step - Next it will match the question.CommCare_External__ID__c to the CommCare questions such as "drugs_and_alcohol_use.how_often_drugs" found in the
form.risk_assessment.[*]
andupdate
theampi__Picklist_Response__c
field for each question
- Referral records - When service referrals are completed (based on the presence of referral services data)
- In the form we receive from CommCare there is an object named
form.referral_services
. Inside this object there will be a list of referal services such asmental_health_services
,legal_services
,hiv_support__care
,child_protection_support_services
,art_support_services
. - If each of the
referral_services
have value, then we need to create aReferral_Service__c
object in Amp Impact
To Create a Referral_Service__c
-
First we need to query for a
GRS_Service__c
using commcare external id that matches the key of the referral service. (E.gart_support_services
) -
Then we construct and upsert the
Referral_Service__c
object by following the mapping spec and using the ID we got in the previous step as an id forGRS_Service__c
-
New Data Model Reference: link
-
Mapping Specification: link
Data Volumes & Limits
Each webhook submission processes a single Upsert Risk and Vulnerability Assessment - Service Referral
form with at most one Risk assessment object and one or more referral services for each form submission. There is no batching or volume constraints currently.
Workflow
This has been configured on a new workflow here, which can be edited to map to the new Salesforce data model.
Credentials
Salesforce: GRS SF Sandbox Integration User - May 25
CommCare: GRS CommCare App
Testing Guidance
Use this input to test object creation on Salesforce.
When an Upsert Risk and Vulnerability Assessment - Service Referral
form is created on CommCare ensure that:
- If
state.data.perform_a_risk_assessment
is true: Oneampi__Project__c
has been upserted using externalIdCommCare_External_ID
and multipleampi__Question__c
are updated under it - If the objects under
form.referral_services
have value, one Referral_Service__c has been upserted for each referral_service
Toggl
GRS Redesign 2025
Branch and project
develop
branch- grs-staging project