In many cases, document attachment disabled on processed records. Usually this happened with respect to business requirements. For example when Purchased order invoiced and settled in ledger, attachment add, edit and delete can be disabled. Only existing attachment can be view on these documents.But some cases we have to forcefully enabled document attachment on these processed records.
I used following code snippet to enable the document attachment.
/ <param name="args"></param>
[PostHandlerFor(formStr(DocuView), formMethodStr(DocuView, setEnabled))]
public static void DocuView_Post_setEnabled(XppPrePostArgs args)
{
FormRun formRun;
//= sender;
formRun =Args.getThis();
formrun.design().controlName("ctrlAdd").enabled(true);
FormDataSource DocuRef_DS =formRun.dataSource("DocuRef");
DocuRef_DS.allowEdit(true);
DocuRef_DS.allowCreate(true);
DocuRef_DS.allowDelete(true);
}