ExecuteBulkScalar throws exception, missing property "create"

  • 23 February 2016
  • 2 replies
  • 1 view

Badge +3

In a Blackpearl v4.6.9 environment, calling method ExecuteBulkScalar(SmartObject,SmartObjectList)
(i.e.,
SourceCode.SmartObjects.Client.SmartObjectClientServer.ExecuteBulkScalar
https://www.k2.com/onlinehelp/k2blackpearl/devref/4.6.9/default.htm#../Subsystems/Default/Content/topic9531.html
)
generates an exception. Some exception details:

 

Message

Method 'Create' on SmartObject 'DW.LRP.SMO.CapitalBudget'. Required property 'create' value missing.

Stacktrace

at SourceCode.SmartObjects.Client.SmartObject.Validate(DataTable insertTable)
at SourceCode.SmartObjects.Client.SmartObjectClientServer.ExecuteScalar(SmartObject smartObject, DataTable inputTable)
at SourceCode.SmartObjects.Client.SmartObjectClientServer.ExecuteBulkScalar(SmartObject smartObject, SmartObjectList inputList)
at SourceCode.SmartObjects.Services.ExcelImportService.Import() in c:UsersjwarwickDocumentsVisual Studio 2012ProjectsExcelImportServiceExcelImportServiceDataExcelImportService.cs:line 307
at ScriptableImporter.Program.XLSXimport_LRPCapitalBudget() in c:UsersjwarwickDocumentsVisual Studio 2012ProjectsExcelImportServiceScriptableImporterProgram.cs:line 42
at ScriptableImporter.Program.Main(String[] args) in c:UsersjwarwickDocumentsVisual Studio 2012ProjectsExcelImportServiceScriptableImporterProgram.cs:line 21
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

The call is from a SmartObject interface for a custom service broker (Mr. Fang's excellent ExcelImportService). I have used it successfully before on other, similar SmartObjects based on SQL Server Service service broker.


In the visible definition of the SmartObject (therefore the columns of the target table), there are no columns named 'create'. The documentation ( https://www.k2.com/onlinehelp/k2blackpearl/devref/4.6.9/default.htm#SmartObjects_-_Bulk_Inserts.html?Highlight=executebulkscalar ) does not seem to mention anything like that. On debug, ReferencePropertyCollection "RequiredProperties" for the "Create" method in the elements of the list of SmartObjects supplied as the second argument does not seem to contain anything like that. Any tips or advice on getting more detail or satisfying the ExecuteScalar's requirement for a 'create' property?


2 replies

Badge +3

After some further experimentation, I have discovered that if I disable all of the target SmartOjbect's properties' Required flags, the exception is not thrown. In my simple test case, none of the columns have blank/empty/null cells, so this remains an incomplete explanation.  I cannot trace in Visual Studio because I do not have the source for SourceCode.SmartObjects.Client namespace assemblies. Moreover, the exception message is a bit misleading.

 

 

I'm still confused about what is going on and would welcome any comment or edification.

Badge +3

After further examination, I found that the root problem was an invalid date format. The Excel import service "correctly" returned the content of date-type cells in the Excel-styled date format: a serial number of days since the beginning of the 20th century (  https://support.microsoft.com/en-us/kb/214094 ). At the the "C# level", at the time of SmartObject value assignment, you are actually just filling in string properties, and the conversion to the target value type happens later, automatically (in my case in the call to ExecuteScalar call from ExecuteBulkScalar). At that point, I assume the converting function is expecting a date format that matches the locale settings on the server or the DB. So in the U.S., it should have been something like "1/1/2015" instead of "42005". 

 

So I think I can resolve the issue on my own, but here are my outsanding questions:  

  Has anyone else used Excel ImportService Broker (http://community.k2.com/t5/K2-blackpearl/Excel-Import-Service-Broker/ba-p/65814) with date-type Excel values successfully before? Just want to make sure I have the right version and have not broken it myself.

 

  And for the K2 development team:  did I miss something in my exception inspection process? If not, please consider a more helpful exception message. If I feed in a bad date format, I am confused and mislead by "Required property 'create' value missing."

Reply