Skip to main content
18-Opal
May 17, 2017
Solved

I have question about create thing using snippet

  • May 17, 2017
  • 6 replies
  • 2935 views

I create thing using snippet

n,T is Input parameter

so i create test1

and i want set this property

but Thing was created by snippet couldn't change properties

i input some test message in property Test1 Value

and click Set But

anything change...

.

.

.

but i create Thing using Create Thing in more button

it was changed properties

why i create thing with snippet can't change properties?

how i can make change properties with create thing using snippet?

Best answer by AnnaAn

Hi Sehnho Cha,

Could you do again following below from scratch:

1. in an existing Thing, create a new Service and author it like:


var params = {
name: name /* STRING */,
description: undefined /* STRING */,
thingTemplateName: TemplateName /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};

// no return
Resources["EntityServices"].CreateThing(params);


Things[name].EnableThing();
Things[name].RestartThing();

name, TemplateName is input parameter

2.Go to the thing created by snippet, and add a new property manually, and then set a value for it and see if property is changed.

3. If property is still not changed, please check your new created thing's General Information, and see if the Active is checked.

Thanks,

Br,

Anna

6 replies

14-Alexandrite
May 17, 2017

Dear Seonho Cha,

By default after you programmically create a Thing, it's still inactive. You need Enable it with adding this code in your script:

Things[YOURTHINGNAME].EnableThing();

and try it again.

Thanks,

Br,

Anna

CHASEONHO18-OpalAuthor
18-Opal
May 17, 2017

Thanks Anna An

i try "Things[YOURTHINGNAME].EnableThing();" this script in my script

but doesn't changed...

this is make with create Thing in more button in Template

this thing was Depedns On display

and this is create thing with snippet

and any depends on don't display

is this issue make problem?

how can fix it?

AnnaAn14-AlexandriteAnswer
14-Alexandrite
May 17, 2017

Hi Sehnho Cha,

Could you do again following below from scratch:

1. in an existing Thing, create a new Service and author it like:


var params = {
name: name /* STRING */,
description: undefined /* STRING */,
thingTemplateName: TemplateName /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};

// no return
Resources["EntityServices"].CreateThing(params);


Things[name].EnableThing();
Things[name].RestartThing();

name, TemplateName is input parameter

2.Go to the thing created by snippet, and add a new property manually, and then set a value for it and see if property is changed.

3. If property is still not changed, please check your new created thing's General Information, and see if the Active is checked.

Thanks,

Br,

Anna