Skip to main content
12-Amethyst
May 19, 2017
Question

AddPropertyDefinition on Thingworx display: Must Specify A Property Name

  • May 19, 2017
  • 1 reply
  • 1892 views

Hi, i have an issue adding dynamically properties to a remote template create by snippet.

I get an error reporting this:

JavaException: com.thingworx.common.exceptions.InvalidRequestException: Must Specify A Property Name

this is the code:

//template creation

var paramsRemoteThing = {

    name: "MyTemplate",

    description: "This is the description", // STRING

    thingTemplateName: 'RemoteThing',

    tags: 'MyParent:Template'

};

Resources["EntityServices"].CreateThingTemplate(paramsRemoteThing);

//add a remote property

var paramsIns = {

        defaultValue: undefined , // STRING

        description: undefined , // STRING

        readOnly: false,  // BOOLEAN

        type: "STRING",  // BASETYPENAME

        remote: false , // BOOLEAN

        remotePropertyName: "ThisIsMyNamedProperty" , // STRING

        timeout: undefined , // INTEGER

        pushType: "VALUE" , // STRING

        dataChangeThreshold: undefined,  // NUMBER

        logged: false, // BOOLEAN

        name: "variabile" , // STRING

        pushThreshold: undefined , // NUMBER

        dataChangeType: "VALUE" , // STRING

        category: "remote" , // STRING

        persistent: true, // BOOLEAN

        dataShape: undefined // DATASHAPENAME

    };

    // try to add property

    try{

         ThingTemplates[nomeTemplate].AddPropertyDefinition(paramsIns );

    }catch(e){

         logger.error("ERROR adding proeprty:  "+e)

    }

What am i missing ? after creating is necessary to bind remote property?

1 reply

12-Amethyst
May 19, 2017

You may want to have a look at KCS 237302 which goes through dynamically mapping properties on a Remote Thing.  There is mention of code on the Edge device, though ultimately it is simply triggering the Service defined on the Remote Thing Template to map the properties.

This will only work if you've defined your remote properties on your edge device.  (This example was specifically used with the Java Edge SDK when it was written)

aziliotto12-AmethystAuthor
12-Amethyst
May 30, 2017

Thank you Jeremy!

It was a syntax error, now it works properly!