You need to sign in to do that
Don't have an account?
SyracuseSnow
Apex code clone feature
Can anyone tell me how to create a replica of a SObject using Apex code? For example, when a opportunity is saved, if certain conditions apply, we would like a clone of this opportunity created as a child opportunity to the current one.
I have been trying using sobject.clone() method, but it seems to be designed for a different purpose, and only creates a new pointer, which is not what I am looking for.
Your help is highly appreciated.
I have been trying using sobject.clone() method, but it seems to be designed for a different purpose, and only creates a new pointer, which is not what I am looking for.
Your help is highly appreciated.
Code:
"First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Case: bad field names on insert/update call: IsSelfClosed, IsVisibleInCss: [IsSelfClosed, IsVisibleInCss]: Trigger.AutoCreateSubCase: line 9, column 5"
I don't see these two fields, isSelfClosed and IsVisibleInCss. Not quite sure what I should do.
Thanks,
Can you post your code that is not working?
pat
trigger AutoCreateSubCase on Case (after update) {
List<Case> listCases = new List<Case>();
for(Case c: Trigger.new) {
Case newChildCase = c.clone(false);
newChildCase.ParentId = c.ID;
listCases.add(newChildCase);
}
insert listCases;
}