Code to save and launch spreadsheet with secured scripting and IDM

In this case, the report is attached to an IDM Document Type which can optionally be mapped to an Optiva Function Code. A good practice is to define this Doc Type/Code at the top of the script in a variable. This code excerpt references a script library, IDM_EPPLUS. This library is provided with v12.14 and higher Implementation Accelerator and Base databases. If you have upgraded from an earlier version and would like a copy of this library, please contact Support.

dim filename as string = _actioncode & "_" & cstr(_wipid) & ".xlsx"	' Final Excel file name – use any logic that creates a valid file name. 
	dim doccode as string = "ATTACHMENT"	' Assumes this IDM Doc Type has been configured

		dim oidm as IDM_EPPLUS = New IDM_EPPLUS(me)
		oidm.AttachdocumenttoIDM(pkg.getasbytearray(), filename, doccode, "FORMULA", _Objectkey)
		filename = filename.Replace(".xlsx", "")
		oidm.OpenAttachments(doccode, "FORMULA", _Objectkey, filename)