Skip to content

joaoamilcarosf/object-integration-dx

Repository files navigation

The Object Integration Process

( https://dev.osf-global.com/jira/browse/COBRA-134 )

Deploy this project to a scratch org:

  1. Clone the project.
  1. Push the project to the scratch org.
sfdx force:source:push -u <scratch org username/alias>
  1. Import sample data provided at ./data.
sfdx force:data:tree:import -p data/sample-data-plan.json -u <scratch org username/alias>
  1. Open the scratch org.
sfdx force:org:open -u <scratch org username/alias>

Batch flow:

  1. A first query is performed to find the Metadata record that is activated. Metadata is used for integration settings purposes.
  2. The last value found on this metadata is used to filter another query for the next objects to be processed.
  3. Objects are processed (translated).
  4. Last value for the used metadata is updated. The process is pointed in three basic steps on comments at osf_AccountSourceBatch class.

Testing:

  1. Clone this repository.
  2. Create a scratch org and push this project.
  3. Import records provided on /data/sample-data-plan.json file.
  4. Make changes on osf_Account_Source__c
  5. Open developer console.
  6. Choose a future time (CRON time-based) to run the test job.
  7. Open execute anonymous window, and create an Apex scheduler by running the code bellow.
  8. After the batch is completed, verify changes reflected on osf_Account_Target__c.
osf_AccountSourceSchedule schedule = new osf_AccountSourceSchedule();
String cron = '0 59 10 * * ?';
String jobID = system.schedule('New import job', cron, schedule);
System.debug('Schedule job ID: ' + jobID);

Trigger flow:

  1. A first query is performed to find the Metadata record that is activated. Metadata is used for integration settings purposes.
  2. The triggered object (Trigger.new) is processed (translated).

Testing:

  1. Clone this repository.
  2. Create a scratch org and push this project.
  3. Import records provided on /data/sample-data-plan.json file.
  4. Make sure trigger is activated.
  5. Make changes on osf_Account_Source__c (any field described on Metadata fields map).
  6. Verify changes reflected on osf_Account_Target__c.

If some warn appears or anything goes wrong, please verify the requirements:

  1. Defined both source and target (custom) objects: for this sample code, osf_Account_Source__c and osf_Account_Target__c respectively.
  2. Created a custom metadata type (osf_Account_Mapping__mdt) with the following custom fields, for each source-target pair of objects. Each record of this may represent general instructions about how to proceed with the translation:
  • Active: given it is possible to create many records for a metadata, it is easier to check or uncheck this field to inform which metadata must be considered for the next translations. A priori, only one of them must be checked.
  • Email: provide an email address to be warned with general informations when the batch process of translations is finished.
  • Fields Map: provide a JSON-like with the fields named after source object fields, and values named after the correspondent target object fields. This JSON can be improved with instrucitons to make the whole process easier.
  • Last Value: This field is auto populated after each translation process, with the last LastModifiedDate value among all source objects translated in the last time.
  • Unique Field: this field must be populated with the field name that uniquely correlates source and target objects. It is used for further updates purposes.
  1. Created at least one custom metadata type record and activate it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages