You need to sign in to do that
Don't have an account?
Srinivas223
carrying files to another record
I am using a custom contract object which have the option to amend. The new amendment will carry all the contract info but not carrying its files attached to it. How to carry over the files when we are amending existing contract(amending a contract means it creates a new contract with the old contract info).
I am trying this
Thank you.
I am trying this
public static void carryFilestoAmendments(list<Contract__c> contracts){ list<id> amended = new list<id>(); for(Contract__c con : contracts){ amended.add(con.REVVY__AmendedFrom__c); } list<ContentDocumentLink> files = [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink where LinkedEntityId in: amended and LinkedEntity.Type='MnContract__c']; for(Contract__c con : contracts) for(ContentDocumentLink doc : files){ doc.LinkedEntityId = con.id; } } The error I got on this is Field is not writable. ContentDocumentLink.LinkedEntityIdI appreciate your help.
Thank you.
As the linkedentity of the existing is not writable, clone the contentdocument link and attach it to the record with linkedEntityId.
Thanks!
All Answers
ContentDocumentLink.LinkedEntityId is autofield, you can't able to update values on that field . So your are getting error as " Field is not writable "
doc.LinkedEntityId = con.id;
you can't perform operation on LinkedEntityId .
let us know if it helps you and mark it best if it helps you
Thanks,
Bhanu Prakash
visit ForceLearn (https://www.forcelearn.com)for salesforce Latest Updates and development tips
Thank you for your time.
Do we have anyway to carry files from one record to its amendment?
As the linkedentity of the existing is not writable, clone the contentdocument link and attach it to the record with linkedEntityId.
Thanks!