Copy parent case data to child case












1















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?




  1. 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










share|improve this question


















  • 1





    You just clone the parent case and update parentId to create child case

    – Santanu Boral
    2 days ago











  • @Santanu Boral: This sounds like manual process. Can it be automated?

    – Student
    2 days ago
















1















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?




  1. 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










share|improve this question


















  • 1





    You just clone the parent case and update parentId to create child case

    – Santanu Boral
    2 days ago











  • @Santanu Boral: This sounds like manual process. Can it be automated?

    – Student
    2 days ago














1












1








1








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?




  1. 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










share|improve this question














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?




  1. 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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









StudentStudent

827




827








  • 1





    You just clone the parent case and update parentId to create child case

    – Santanu Boral
    2 days ago











  • @Santanu Boral: This sounds like manual process. Can it be automated?

    – Student
    2 days ago














  • 1





    You just clone the parent case and update parentId to create child case

    – Santanu Boral
    2 days ago











  • @Santanu Boral: This sounds like manual process. Can it be automated?

    – Student
    2 days ago








1




1





You just clone the parent case and update parentId to create child case

– Santanu Boral
2 days ago





You just clone the parent case and update parentId to create child case

– Santanu Boral
2 days ago













@Santanu Boral: This sounds like manual process. Can it be automated?

– Student
2 days ago





@Santanu Boral: This sounds like manual process. Can it be automated?

– Student
2 days ago










1 Answer
1






active

oldest

votes


















5














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.






share|improve this answer
























  • 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
    2 days ago











  • @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
    2 days ago











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
});


}
});














draft saved

draft discarded


















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









5














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.






share|improve this answer
























  • 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
    2 days ago











  • @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
    2 days ago
















5














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.






share|improve this answer
























  • 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
    2 days ago











  • @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
    2 days ago














5












5








5







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Daniel BallingerDaniel Ballinger

72.6k15149392




72.6k15149392













  • 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
    2 days ago











  • @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
    2 days ago



















  • 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
    2 days ago











  • @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
    2 days ago

















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
2 days ago





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
2 days ago













@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
2 days ago





@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
2 days ago


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?