/
/golden

/golden

The process contains syncing golden individual data with SFDC.

Mule process:

Input data:

[ "IndividualId1", "IndividualId2" ]

Process:

  1. Required header “validator“ with value: rbesb

  2. Request Epsilon for a token (It is needed to be moved to middleware Mulesoft)

  3. For each individual id

    1. Get from CDP - Golden Individual - saved under “profile”

    2. Get from CDP - Contacts - export from its contact and save under “emails”, “phones”

    3. Map enrollments - if there are any children, gather all enrollments and save them under “enrollChildren”

    4. Sync process:

      1. Check Contact

        1. Query Object: Account with several conditions (SFSC)

          var boc = if (vars.profile.BrandOrgCode == 'MJNTHA') "TH_Household" else if (vars.profile.BrandOrgCode == 'MJNIDN') "ID_Household" else if (vars.profile.BrandOrgCode == 'MJNMYS') "MY_Household" else if (vars.profile.BrandOrgCode == 'MJNSGP') "MY_Household" else if (vars.profile.BrandOrgCode == 'MJNBRN') "MY_Household" else if (vars.profile.BrandOrgCode == 'MJNVNM') "VN_Household" else null
          SELECT Id, OwnerId, Inactive__c FROM Account WHERE IsDeleted=false AND RecordMarket__c= ++ boc ++ AND ++ QUERIES EMAILS OR PHONES (Depending if values exists)

          It is saved later in a variable: “contactQueryResponse”

        2. If contacts do not exist = logger. If contacts exist then:

          1. Filter contacts if Inactive__c == “false”. If false then = logger, if true then:

            1. Load data from vars to payload

            2. Query data for parents (SFSC):

              Data is saved into a variable: “contactQueryResponse”

            3. If parents exist: for each parent there are transformations made. If parents do not exist it just logs proper information.

        3. Mapping Household

          1. Prepare new_account variable: (Variables inside DW)

            Mapping:

            If values are not blank then it is appended to the payload. In another case, the whole key is deleted from the request. All data are in vars. (It can cause memory issues later if data is larger).

          2. Prepare cityData variable:

          3. If Profile ID SF is equal to profile ID from CDP

            1. For each: JsonExternalData

            2. If payload profile id equals correctly and mom status is not empty and mom status is equal to first time then

            3. Mom_status equals: "1st Time"

            4. In other case logger

          4. if Profile ID SF is NOT equal to profile ID from CDP

            1. If ProfileSubscriptions and JsonExternalData are not empty for each profile subscription do:

            2. If optStatus is true and channelCode contains channelCode(??? payload.OptStatuss == true and !(payload.ChannelCode contains payload.ChannelCode) ???) prepare parse_subs which is currently empty object in other case it also empty object

          5. Prepare subscriptions in payload

            Adding to new_account object (and saving to payload)

        4. The query is being prepared for the city - Long logic - Object City__c

        5. Query City (SF)

          1. Does city query have at least 3 query conditions? if true then

            1. Query City

            2. if value is not empty it is appending additional data to vars with account

            3. In other cases it logs information

          2. If false then

            1. Creates/Updates a household data into SF (Object Account

        6. CDP - SFDC Sync - Upsert contact If parentIdQueryResponse is empty this one is skipped in other cases:

          1. Create def_data variable:

          2. If a Child should be created - Sync children - (MAPPING ONLY)

            1. Mapping - Most data is from payload. Need to be validated when running

          3. In this process, there are multiple for each using extra_data and even extra_data.Children (Why not payload.Children)

        7. Big choice which contains

          1. !isEmpty(vars.new_children) and vars.create_child == true - only logger (Missing implementation?)

          2. isEmpty(vars.new_children) and vars.create_child == true - Only logger - no children to upsert

          3. !isBlank(vars.def_data.contact_id) - Contains logger that should be updated but creates Contact Parent

          4. default - Creates Contact Parent It is double the same logic

        8. Contains Logger TODO - What is missing Syncing children? enrollments?

  4. End of the process