Copy parent case data to child case
I have 50+ fields on case object. There are multiple related/child cases under one parent case. The parent case is populated with some data. Is there a way through which we can copy data from parent case to child case as soon as child cases are created as the parent and child case have same fields?
Note: I already know that it can be done via process builder by using update feature and mapping parent and child fields but it's such a waste of time because I have 50+ fields so it will take along time. Is there a quicker way to just copy data from parent to child?
- I also know that I can create formula fields on child cases but it will be unnecessarily repetition of same fields e.g field 'Description' already exists on both Parent and Child case. I just want to copy the data rather than creating a formula field on child case with the name 'Description 2' that references the 'Description' field on parent case.
Kindly let me know if there is a time saving and efficient solution?
Thanks
case
add a comment |
I have 50+ fields on case object. There are multiple related/child cases under one parent case. The parent case is populated with some data. Is there a way through which we can copy data from parent case to child case as soon as child cases are created as the parent and child case have same fields?
Note: I already know that it can be done via process builder by using update feature and mapping parent and child fields but it's such a waste of time because I have 50+ fields so it will take along time. Is there a quicker way to just copy data from parent to child?
- I also know that I can create formula fields on child cases but it will be unnecessarily repetition of same fields e.g field 'Description' already exists on both Parent and Child case. I just want to copy the data rather than creating a formula field on child case with the name 'Description 2' that references the 'Description' field on parent case.
Kindly let me know if there is a time saving and efficient solution?
Thanks
case
1
You just clone the parent case and update parentId to create child case
– Santanu Boral
Jan 21 at 18:24
@Santanu Boral: This sounds like manual process. Can it be automated?
– Student
Jan 21 at 18:43
add a comment |
I have 50+ fields on case object. There are multiple related/child cases under one parent case. The parent case is populated with some data. Is there a way through which we can copy data from parent case to child case as soon as child cases are created as the parent and child case have same fields?
Note: I already know that it can be done via process builder by using update feature and mapping parent and child fields but it's such a waste of time because I have 50+ fields so it will take along time. Is there a quicker way to just copy data from parent to child?
- I also know that I can create formula fields on child cases but it will be unnecessarily repetition of same fields e.g field 'Description' already exists on both Parent and Child case. I just want to copy the data rather than creating a formula field on child case with the name 'Description 2' that references the 'Description' field on parent case.
Kindly let me know if there is a time saving and efficient solution?
Thanks
case
I have 50+ fields on case object. There are multiple related/child cases under one parent case. The parent case is populated with some data. Is there a way through which we can copy data from parent case to child case as soon as child cases are created as the parent and child case have same fields?
Note: I already know that it can be done via process builder by using update feature and mapping parent and child fields but it's such a waste of time because I have 50+ fields so it will take along time. Is there a quicker way to just copy data from parent to child?
- I also know that I can create formula fields on child cases but it will be unnecessarily repetition of same fields e.g field 'Description' already exists on both Parent and Child case. I just want to copy the data rather than creating a formula field on child case with the name 'Description 2' that references the 'Description' field on parent case.
Kindly let me know if there is a time saving and efficient solution?
Thanks
case
case
asked Jan 21 at 18:19
StudentStudent
847
847
1
You just clone the parent case and update parentId to create child case
– Santanu Boral
Jan 21 at 18:24
@Santanu Boral: This sounds like manual process. Can it be automated?
– Student
Jan 21 at 18:43
add a comment |
1
You just clone the parent case and update parentId to create child case
– Santanu Boral
Jan 21 at 18:24
@Santanu Boral: This sounds like manual process. Can it be automated?
– Student
Jan 21 at 18:43
1
1
You just clone the parent case and update parentId to create child case
– Santanu Boral
Jan 21 at 18:24
You just clone the parent case and update parentId to create child case
– Santanu Boral
Jan 21 at 18:24
@Santanu Boral: This sounds like manual process. Can it be automated?
– Student
Jan 21 at 18:43
@Santanu Boral: This sounds like manual process. Can it be automated?
– Student
Jan 21 at 18:43
add a comment |
1 Answer
1
active
oldest
votes
I'd probably go with a trigger and the sObject.getPopulatedFieldsAsMap()
method.
When the child case is created you have the trigger query all the parent cases fields that you want to copy over. Then run through the getPopulatedFieldsAsMap() Map keys and copy the values from the parent case to the child case using .get(field)
and .put(field)
.
It would also be worth bulkifying so that each parent case is only only queried once and then mapped back to the appropriate child case.
Thanks for the solution. This sounds like a good approach as I will only have to write the code once. Rest the trigger will take care of it. I will work on implementing this. Thanks again.
– Student
Jan 21 at 18:46
@Student The only outstanding question is how dynamic you want to make it. As proposed, the fixed SOQL query for the parent case would define which fields are cloned. If you want to go all in on making it dynamic you could use the Case field metadata to build the SOQL query with just those fields that can be cloned.
– Daniel Ballinger
Jan 21 at 18:54
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f247427%2fcopy-parent-case-data-to-child-case%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'd probably go with a trigger and the sObject.getPopulatedFieldsAsMap()
method.
When the child case is created you have the trigger query all the parent cases fields that you want to copy over. Then run through the getPopulatedFieldsAsMap() Map keys and copy the values from the parent case to the child case using .get(field)
and .put(field)
.
It would also be worth bulkifying so that each parent case is only only queried once and then mapped back to the appropriate child case.
Thanks for the solution. This sounds like a good approach as I will only have to write the code once. Rest the trigger will take care of it. I will work on implementing this. Thanks again.
– Student
Jan 21 at 18:46
@Student The only outstanding question is how dynamic you want to make it. As proposed, the fixed SOQL query for the parent case would define which fields are cloned. If you want to go all in on making it dynamic you could use the Case field metadata to build the SOQL query with just those fields that can be cloned.
– Daniel Ballinger
Jan 21 at 18:54
add a comment |
I'd probably go with a trigger and the sObject.getPopulatedFieldsAsMap()
method.
When the child case is created you have the trigger query all the parent cases fields that you want to copy over. Then run through the getPopulatedFieldsAsMap() Map keys and copy the values from the parent case to the child case using .get(field)
and .put(field)
.
It would also be worth bulkifying so that each parent case is only only queried once and then mapped back to the appropriate child case.
Thanks for the solution. This sounds like a good approach as I will only have to write the code once. Rest the trigger will take care of it. I will work on implementing this. Thanks again.
– Student
Jan 21 at 18:46
@Student The only outstanding question is how dynamic you want to make it. As proposed, the fixed SOQL query for the parent case would define which fields are cloned. If you want to go all in on making it dynamic you could use the Case field metadata to build the SOQL query with just those fields that can be cloned.
– Daniel Ballinger
Jan 21 at 18:54
add a comment |
I'd probably go with a trigger and the sObject.getPopulatedFieldsAsMap()
method.
When the child case is created you have the trigger query all the parent cases fields that you want to copy over. Then run through the getPopulatedFieldsAsMap() Map keys and copy the values from the parent case to the child case using .get(field)
and .put(field)
.
It would also be worth bulkifying so that each parent case is only only queried once and then mapped back to the appropriate child case.
I'd probably go with a trigger and the sObject.getPopulatedFieldsAsMap()
method.
When the child case is created you have the trigger query all the parent cases fields that you want to copy over. Then run through the getPopulatedFieldsAsMap() Map keys and copy the values from the parent case to the child case using .get(field)
and .put(field)
.
It would also be worth bulkifying so that each parent case is only only queried once and then mapped back to the appropriate child case.
answered Jan 21 at 18:26
Daniel BallingerDaniel Ballinger
72.7k15149392
72.7k15149392
Thanks for the solution. This sounds like a good approach as I will only have to write the code once. Rest the trigger will take care of it. I will work on implementing this. Thanks again.
– Student
Jan 21 at 18:46
@Student The only outstanding question is how dynamic you want to make it. As proposed, the fixed SOQL query for the parent case would define which fields are cloned. If you want to go all in on making it dynamic you could use the Case field metadata to build the SOQL query with just those fields that can be cloned.
– Daniel Ballinger
Jan 21 at 18:54
add a comment |
Thanks for the solution. This sounds like a good approach as I will only have to write the code once. Rest the trigger will take care of it. I will work on implementing this. Thanks again.
– Student
Jan 21 at 18:46
@Student The only outstanding question is how dynamic you want to make it. As proposed, the fixed SOQL query for the parent case would define which fields are cloned. If you want to go all in on making it dynamic you could use the Case field metadata to build the SOQL query with just those fields that can be cloned.
– Daniel Ballinger
Jan 21 at 18:54
Thanks for the solution. This sounds like a good approach as I will only have to write the code once. Rest the trigger will take care of it. I will work on implementing this. Thanks again.
– Student
Jan 21 at 18:46
Thanks for the solution. This sounds like a good approach as I will only have to write the code once. Rest the trigger will take care of it. I will work on implementing this. Thanks again.
– Student
Jan 21 at 18:46
@Student The only outstanding question is how dynamic you want to make it. As proposed, the fixed SOQL query for the parent case would define which fields are cloned. If you want to go all in on making it dynamic you could use the Case field metadata to build the SOQL query with just those fields that can be cloned.
– Daniel Ballinger
Jan 21 at 18:54
@Student The only outstanding question is how dynamic you want to make it. As proposed, the fixed SOQL query for the parent case would define which fields are cloned. If you want to go all in on making it dynamic you could use the Case field metadata to build the SOQL query with just those fields that can be cloned.
– Daniel Ballinger
Jan 21 at 18:54
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f247427%2fcopy-parent-case-data-to-child-case%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You just clone the parent case and update parentId to create child case
– Santanu Boral
Jan 21 at 18:24
@Santanu Boral: This sounds like manual process. Can it be automated?
– Student
Jan 21 at 18:43