Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 3 Next »

The process contains syncing golden individual data with SFDC.

Mule process:

Input data:

[
  "IndividualId1",
  "IndividualId2"
]

Process :

EXPIRIENCE API:

  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):

              SELECT Id, RecordMarket__c, Inactive__c FROM Contact WHERE Is_Primary_Contact__c=true AND IsDeleted=false AND AccountId='" + vars.'account_id' + "' 

              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)

            fullname: profileFirstName ++ profileMiddleName ++ profileLastName
            Coutry_TXT mapping: {
            	"THA": "Thailand",
            	"VNM": "Vietnam",
            	"SGP": "Singapore",
            	"MYS": "Malaysia",
            	"BRN": "Brunei",
            	"IDN": "Indonesia",
            	"PHL": "Philippines",
            	"USA": "USA"
            }

            Mapping:

            First_Name__c: profileFirstName
            Last_Name__c: profileLastName
            Middle_Name__c: profileMiddleName
            Name: fullName
            Id: def_data.account_id
            RecordTypeId: profileBrandOrgCode
            Address_Line_1__c: profileAddressLine1
            Address_Line_2__c: profileAddressLine2
            Address_Remarks__c: profileJsonExternalData.AddressRemarks
            Mobile_Phone__c: profileMobilePhone
            Home_phone__c: profileHomePhone
            Home_phone__c: profileHomePhone splitBy("x"))[0]
            Home_Phone_Extension__c: (profileHomePhone splitBy("x"))[1]))
            Other_Phone_1__c: profileWorkPhone
            Other_Phone_1__c: profileOtherPhone
            Account_Email__c: profileEmailAddress
            Member_Country__c: COUNTRY_TXT[vars.profileCountryCode]

            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:

            District__c: profileAddressLine3 -> with additonal logic of splitting data
            Region__c: profileAddressLine3 -> with additional logic of splitting data
            Name: profileCity
            State_Province__c: profileState
            Zip_Code__c: profilePostalCode
            Country__c: COUNTRY_TXT[vars.profileCountryCode] //This element should not work there is no COUNTRY_TXT in dataweave
          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 (question) in other case it also empty object (question)

              %dw 2.0
              output application/json
              var s_optstatus = payload.OptStatus
              var s_channel = payload.ChannelCode
              var upsert_channel = false
              ---
              {}
              	//		subscribes[s_channel] = subscriptions[s];
              	//		upsert_channel = true; 
          5. Prepare subscriptions in payload

            var most_recent = (vars.enrollChildren orderBy ((item, index) -> -item.enrollDate as DateTime as Number {unit: "milliseconds"}))[0]

            Adding to new_account object (and saving to payload)

            Mailing_Opt_Out__c: true (hardcoded)
            Account_Email_Opt_out__c: true (hardcoded)
            Do_not_SMS_Mobile__c: true (hardcoded)
            Do_Not_Call_Mobile__c: true (hardcoded)
            Do_Not_Call_Home_Phone__c: true (hardcoded)
            Do_Not_Call_Other_Phone_1__c: true (hardcoded)
            Enfa_Status__c: most_recent.'Enfa_Status__c' <- added if most_recent.'Enfa_Status__c' == "Active"
            Enfa_Date_Joined__c: most_recent.enrollDate <- added if most_recent.'Enfa_Status__c' == "Active"
            Sustagen_Status__c: most_recent.'Enfa_Status__c'
            Sustagen_Date_Joined__c: most_recent.enrollDate
            Mom_Status__c: vars.Mom_Status <- added if !isBlank(vars.Mom_Status)
        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:

            if (vars.createContactParentResponse !=null)
            {
            	'contact_id': vars.createContactParentResponse.id,
            	'account_id': vars.def_data.account_id
            }
            else if (vars.updateContactParentResponse !=null)
            {
            	'contact_id': vars.updateContactParentResponse.id,
            	'account_id': vars.def_data.account_id
            }
            else "Parent Response not chosen"
          2. If a Child should be created - Sync children - (MAPPING ONLY)

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

              var CHILD = {
              	'MJNTHA': "0129000000168Ip",
              	'MJNIDN': '0129000000168Ij',
              	'MJNBRN': '0129000000168Il',
              	'MJNMYS': '0129000000168Il',
              	'MJNSGP': '0129000000168Il',
              	'MJNPHL': '',
              	'MJNVNM': '0129000000168Ir'
              }
              ---
              Family_Relationship__c: CaregiverTypeCode
              FirstName: ChildFirstName
              LastName: ChildLastName
              Middle_Name__c: ChildMiddleName
              RecordTypeId: CHILD[vars.profile.BrandOrgCode]
              AccountId: 'def_data'.'acc_id'
              Gender__c: GenderCode
              Birthdate: BirthDueDate
              Last_Consumption_Brand__c: PreferredBrand
              prod_id: PreferredProduct 
              Feeding_Method__c: PreferredProduct
              Born_Hospital__c: HospitalId
              Baby_Hospital__c: HospitalId
              Attending_Doctor__c: HcpProfileId
          3. In this process there are multiple for each using extra_data and even extra_data.Children (question) (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) - (question) Contains logger that it should be update but creates Contact Parent

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

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

  4. End of the process

Python process:

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.