I have written a small code snippet:
public void setAttachment()
{
renderForm = false;
System.debug('renderForm is'+renderForm);
String fileContent = ApexPages.currentPage().getParameters().get('fileContent');
upsert dFlow;
if (fileContent.length() > 23)
{
attachment.Body = EncodingUtil.base64Decode(fileContent.substring(5+11+7));
if(attachment.ParentId == null)
attachment.ParentId = dFlow.Id;
upsert attachment;
}
}
When I call this function via actioncall, it's giving me an error:
Field is not writeable: Attachment.ParentId
How do I associate an attachment with a custom object?