Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
When I happen to use FindDataTableEntries on DataTable, by setting multiple rows in Values Infotable, I get an error as below
Unable to Invoke Service FindDataTableEntries on WA_SampleGuidNameProductionValueTable : Invalid Number of values provided to FindDataTableEntries in WA_SampleGuidNameProductionValueTable
But FindDataTableEntries work for single row in Values infotable.
Anirudha, I believe FindDataTableEntries input parameter is not intended to work with a multiple row infotable. It only accepts a single row infotable, tries to match the specified values and then print them.
Ok, Then which service to use if I have multiple values.
I tried using QueryDataTableEntries as below, but I don't get any values. What is the right way to use QueryDataTableEntries?
I appreciate your reply, I am stuck into an critical issue and it is affecting our production server. Please help.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
var str1 = "19be81d24259853a99fc15fdcda63934521bae29";
var str2 = "2052527c1afe8af884d387d544ab2d2b3c0e1ab9";
var jsonArray = [str1, str2];
var query = {
filters: {
type : "EQ",
fieldName : "guid",
values: jsonArray
}
};
var values = me.CreateValues();
var params = {
maxItems: undefined /* NUMBER */,
values: values /* INFOTABLE*/,
query: query /* QUERY */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
};
// result: INFOTABLE dataShape: "undefined"
var result = me.QueryDataTableEntries(params);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Please note that there is typo, The type I have used is "IN"
Maybe you can call FindDataTableEntries twice (once for each different value), and then join the results together.
If I try doing a call FindDataTableEntries twice (once for each different value), and then join the results together, then showhow I am getting an error in the stack due to which the CPU is getting utilized heavily.
The code snippet is as below
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
for (var x = 0; x < tableLength; x++) {
var str = scns.rows
var values = me.CreateValues();
values.str= str; //STRING
var params = {
values: values /* INFOTABLE*/
};
// result: INFOTABLE dataShape: "undefined"
var queryresult = me.FindDataTableEntries(params);
var tableSize = queryresult.rows.length;
for (var x = 0; x < tableSize; x++) {
var entry = new Object();
entry.guid = queryresult.rows
entry.guidname = queryresult.rows
result.AddRow(entry)
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The stacktrace is as below.
"ajp-nio-8009-exec-4" #355 daemon prio=5 os_prio=0 tid=0x00007f0958008000 nid=0x5e72 runnable [0x00007f0a52988000]
java.lang.Thread.State: RUNNABLE
at java.lang.StringCoding.decode(StringCoding.java:229)
at java.lang.String.<init>(String.java:463)
at java.lang.String.<init>(String.java:515)
at com.thingworx.common.utils.EnhancedDataInputStream.readUTF8(EnhancedDataInputStream.java:35)
at com.thingworx.types.primitives.StringPrimitive.readFromStream(StringPrimitive.java:98)
at com.thingworx.types.BaseTypes.ReadPrimitiveFromStream(BaseTypes.java:736)
at com.thingworx.types.data.util.ValueCollectionSerializer.fromBinary(ValueCollectionSerializer.java:89)
at com.thingworx.types.data.util.ValueCollectionSerializer.fromByteArray(ValueCollectionSerializer.java:136)
at com.thingworx.persistence.neo4j.factories.data.NeoDataEntryDataProvider.readDataEntryFromNeo(NeoDataEntryDataProvider.java:61)
at com.thingworx.persistence.neo4j.factories.data.NeoDataTableEntryDataProvider.getDataTableEntry(NeoDataTableEntryDataProvider.java:289)
at com.thingworx.persistence.neo4j.factories.data.NeoDataTableEntryDataProvider.rawQueryEntries(NeoDataTableEntryDataProvider.java:242)
at com.thingworx.persistence.neo4j.factories.data.NeoDataTableEntryDataProvider.queryEntries(NeoDataTableEntryDataProvider.java:528)
at com.thingworx.persistence.neo4j.factories.data.NeoDataTableEntryDataProvider.queryEntries(NeoDataTableEntryDataProvider.java:538)
at com.thingworx.persistence.common.DataTableEngine.lambda$findEntries$69(DataTableEngine.java:229)
at com.thingworx.persistence.common.DataTableEngine$$Lambda$60/580017954.get(Unknown Source)
at com.thingworx.persistence.common.BaseEngine.createTransactionAndReturn(BaseEngine.java:174)
at com.thingworx.persistence.common.DataTableEngine.findEntries(DataTableEngine.java:226)
at com.thingworx.datatables.DataTableThing.FindDataTableEntries(DataTableThing.java:738)
at sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.thingworx.common.processors.ReflectionProcessor.processService(ReflectionProcessor.java:119)
at com.thingworx.handlers.ReflectionServiceHandler.processService(ReflectionServiceHandler.java:47)
at com.thingworx.things.Thing.processServiceRequestDirect(Thing.java:4578)
at com.thingworx.things.Thing.processServiceRequest(Thing.java:4501)
at com.thingworx.dsl.engine.adapters.VirtualFunction.call(VirtualFunction.java:131)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
at org.mozilla.javascript.gen.WA_getGuidAndGuidNames2Columns_922._c_script_0(WA_getGuidAndGuidNames2Columns:21)
at org.mozilla.javascript.gen.WA_getGuidAndGuidNames2Columns_922.call(WA_getGuidAndGuidNames2Columns)
at org.mozilla.javascript.gen.WA_getGuidAndGuidNames2Columns_922.exec(WA_getGuidAndGuidNames2Columns)
at com.thingworx.dsl.engine.DSLProcessor.executeService(DSLProcessor.java:154)
at com.thingworx.dsl.DSLServiceHandler.processService(DSLServiceHandler.java:38)
at com.thingworx.things.Thing.processServiceRequestDirect(Thing.java:4578)
at com.thingworx.things.Thing.processServiceRequest(Thing.java:4501)
at com.thingworx.dsl.engine.adapters.VirtualFunction.call(VirtualFunction.java:131)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
at org.mozilla.javascript.gen.WA_getGuidNames_948._c_script_0(WA_getGuidNames:20)
at org.mozilla.javascript.gen.WA_getGuidNames_948.call(WA_getGuidNames)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3090)
at org.mozilla.javascript.gen.WA_getGuidNames_948.call(WA_getGuidNames)
at org.mozilla.javascript.gen.WA_getGuidNames_948.exec(WA_getGuidNames)
at com.thingworx.dsl.engine.DSLProcessor.executeService(DSLProcessor.java:154)
at com.thingworx.dsl.DSLServiceHandler.processService(DSLServiceHandler.java:38)
at com.thingworx.things.Thing.processServiceRequestDirect(Thing.java:4578)
at com.thingworx.things.Thing.processAPIServiceRequest(Thing.java:4513)
at com.thingworx.webservices.BaseService.handleInvoke(BaseService.java:2513)
at com.thingworx.webservices.BaseService.service(BaseService.java:306)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
Thanks
Anirudha
your code uses 'x' for both loops