Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
What is the best way to set logged = true against all thing properties through a service
Solved! Go to Solution.
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
Hi @asekar are you looking to use something other than GetPropertyLogging service? Could you elaborate a bit more on the actual use case?
@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
@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