Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hello everyone,
I've been trying to create 'Thing' in a batch mode, and I've decided to use the Resources["EntityServices"] CreateThing().
The service seems to work as intended. However, I can verify that the 'Thing' properties of my newly created Thing do not have the 'Default Values' I have configured. Has anyone had an issue with this in the past?
Note: I'm using v8.4.1
Solved! Go to Solution.
For your reference , this is the service code I am using
var text = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for ( var i = 0; i < 6; i++ ) {
text += characters.charAt(Math.floor(Math.random() * i));
}
try {
var params = {
name: text /* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'MyThingTemplate' /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};
// no return
Resources["EntityServices"].CreateThing(params);
}
catch (err)
{
logger.warn (err.message);
}
try {
Things[text].EnableThing();
Things[text].RestartThing();
}
catch (err)
{
logger.warn (err.message);
}
Please define ThingTemplate with name "MyThingTemplate" with default property values before using above service code.
Hi,
Are you creating Thing from specific ThingTemplate which have some properties with default values ? If you are creating thing from Generic Thing template, then how you are setting default property values on thing . Please share that code.
Hello @vinakumar ,
I'm creating a thing from a specific ThingTemplate which has some properties with default values.
I am not seeing any issue at my end in seeing the default property values for Things created dynamically.
Hi
As of now I tested on version 8.4.5 and found it working for me . Will test on 8.4.1 version too.
Yes it is working for me on 8.4.1 too .
Please open tech support case to investigate your entity and service code you are using .
For your reference , this is the service code I am using
var text = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for ( var i = 0; i < 6; i++ ) {
text += characters.charAt(Math.floor(Math.random() * i));
}
try {
var params = {
name: text /* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'MyThingTemplate' /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};
// no return
Resources["EntityServices"].CreateThing(params);
}
catch (err)
{
logger.warn (err.message);
}
try {
Things[text].EnableThing();
Things[text].RestartThing();
}
catch (err)
{
logger.warn (err.message);
}
Please define ThingTemplate with name "MyThingTemplate" with default property values before using above service code.