Hello,using the following code,i'm trying to add a document to a table; however i can not see anything added in document management.The code also doesn't give any errors, any ideas how to resolve it ?
DocuRef docuRef; DocuActionArchive archive; erm_OperationInstructions oprinst; Name _name = "C:\\test.txt"; select firstOnly * from oprinst where oprinst.OperationId == 'OP0001002'; try { ttsBegin; docuRef.clear(); docuRef.RefRecId = oprinst.RecId; docuRef.RefTableId = tableNum(erm_OperationInstructions); docuRef.RefCompanyId = curext(); docuRef.Name = "testfile"; docuRef.TypeId = 'FILE'; docuRef.insert(); archive = new DocuActionArchive(); archive.add(docuRef, _name); ttsCommit; } catch(Exception::Error) { info(strfmt("%1",Exception::Error)); }
*This post is locked for comments
Hey all,with the following code,it works:
ttsbegin; docuref.TypeId = "TYPEIV"; docuref.Name = _name; docuref.Notes = docuRef.Notes; docuRef.Restriction = DocuRestriction::Internal; docuref.RefCompanyId = curext(); docuref.RefTableId = tablenum(OperationInstructions); docuref.RefRecId = oprinst.RecId; docuref.insert(); docuvalue.initValue(); docuvalue.insert(); docuref.ValueRecId = docuvalue.RecId; docuref.update(); docuvaluerecid = docuvalue.RecId; select forupdate docuvalue where docuvalue.recid == docuvaluerecid; docuvalue = docuvalue::writeDocuValue(docuref,_name+".xlsx"); ttscommit;
Set a breakpoint in the DocuActionArchive\add() method and follow the execution path. Depending on how your Document type of FILE is setup in your system, many things could be going wrong. Some of the errors that can occur would not be caught by a catch(Exception::Error) either, so there might not be any visible results. The UI has a nasty habit of not surfacing CLR or COM errors, for example, like it does X++ errors.
Have you looked into DocuRef table and verify whether the records are created there ?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156