cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

EntityServices CreateThing Service does not apply Default Values

SOLVED
Highlighted
Regular Member

EntityServices CreateThing Service does not apply Default Values

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

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.

View solution in original post

8 REPLIES 8
Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

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.

Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

Hello @vinakumar ,

 

I'm creating a thing from a specific ThingTemplate which has some properties with default values.

Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

I am not seeing any issue at my end in seeing the default property values for Things created dynamically.

Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

@vinakumar  which version are you using?

Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

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.

 

Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

@vinakumar let me know if u manage to test it in version 8.4.1

Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

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 .

Highlighted

Re: EntityServices CreateThing Service does not apply Default Values

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.

View solution in original post

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!