Reputation: 56
I have data coming to a salesforce object from a third party tool like this:
ID | field1 | field2 | criteria1importance | criteria1score | criteria1competitorscore | criteria2importance | criteria2score | criteria2competitorscore |criteriaN...
i want to split this in a parent child relationship like this :
parent object : ID | field1 | field2 | criteria(foreign key)
and child object : criteriaName | importance | score | competitorScore
hope that makes sence, i have been searching for this since 2 weeks :/ Thanks in advance.
Upvotes: 1
Views: 1236
Reputation: 56
Problem solved, i have created the child object and an apex trigger to fill the fields. this is how it looks like:
trigger ResultChildTrigger on VANG_Survey_Result__c (after insert) {
List<SurveyDetail__c> details = new List<SurveyDetail__c>();
for (VANG_Survey_Result__c newResult: Trigger.New) {
//if (newResult.Id != null) {
details.add(new SurveyDetail__c(
Name = 'Overall Sales Approach',
Survey_Result__c = newResult.Id,
importance__c = decimal.valueOf(newResult.Q1Value__c),
score__c = decimal.valueOf(newResult.Q2Value__c),
competitor_score__c = decimal.valueOf(newResult.Q3Value__c)
));
}
insert details;
}
Upvotes: 1