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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

What is the best way to set logged = true against all thing properties through a service

asekar
14-Alexandrite

What is the best way to set logged = true against all thing properties through a service

What is the best way to set logged = true against all thing properties through a service

ACCEPTED SOLUTION

Accepted Solutions

Hi!

 

You can use my script:

 

var params = {
	category: undefined /* STRING */,
	type: undefined /* BASETYPENAME */,
	dataShape: undefined /* DATASHAPENAME */
};
// result: INFOTABLE dataShape: "PropertyDefinition"
var properties = me.GetPropertyDefinitions(params);

for(var i=0; i<properties.getRowCount(); i++){
	if(!isDefault(properties[i]['name'])){
    	var params = {
            propertyName: properties[i]['name'] /* STRING */,
            enabled: true /* BOOLEAN */
        };
        me.SetPropertyLogging(params);
    }
}

function isDefault(needle)
{
    var defaults = ['name', 'tags', 'thingTemplate', 'description'];
    return (defaults.indexOf(needle) > -1);
}    

It is checking also if property is deafult or not, so it should be exactly what you are looking for.

 

Best Regards,

Adam

View solution in original post

4 REPLIES 4
supandey
19-Tanzanite
(To:asekar)

Hi @asekar are you looking to use something other than GetPropertyLogging service? Could you elaborate a bit more on the actual use case?

asekar
14-Alexandrite
(To:supandey)


@supandey wrote:

Hi @asekar are you looking to use something other than GetPropertyLogging service? Could you elaborate a bit more on the actual use case?


I have many properties already created against a thing. I want to make all these properties "logged". I see that I can use a service SetPropertyLogged. But I will have to pass in each property separately. If there is a way to automatically set logged = true for all the properties, it would make my job easier

supandey
19-Tanzanite
(To:asekar)

@asekar I don't think there is any out of the box setting that you can enable to make all thing's properties to log. You likely will have to create a custom service which will check this for all the things whose property you want to log and then enable them.

 

May be for all the future creation of Thing and their properties you could include this check in the service (i.e. if you are creating things programatically)

Hi!

 

You can use my script:

 

var params = {
	category: undefined /* STRING */,
	type: undefined /* BASETYPENAME */,
	dataShape: undefined /* DATASHAPENAME */
};
// result: INFOTABLE dataShape: "PropertyDefinition"
var properties = me.GetPropertyDefinitions(params);

for(var i=0; i<properties.getRowCount(); i++){
	if(!isDefault(properties[i]['name'])){
    	var params = {
            propertyName: properties[i]['name'] /* STRING */,
            enabled: true /* BOOLEAN */
        };
        me.SetPropertyLogging(params);
    }
}

function isDefault(needle)
{
    var defaults = ['name', 'tags', 'thingTemplate', 'description'];
    return (defaults.indexOf(needle) > -1);
}    

It is checking also if property is deafult or not, so it should be exactly what you are looking for.

 

Best Regards,

Adam

Announcements


Top Tags