[Imported] ValidateConfiguration method for CDBObject
>>Message imported from previous forum - Category:Scripts and Tips<< User: mchartrand, originally posted: 2018-10-25 19:13:28 Id:275 This is a re-posting from the obsoleted (October 2018) "Schneider Electric Telemetry & SCADA" forum.
**_Von: Hey all: What is the intended use for ValidateConfiguration? To "Save" an object? I tried calling the method in script and it doesn't do anything.._**
dmercer: Hi Von,
Did you find that method in the database schema? (http://localhost/schema/CDBObject)
The description there seems to cover it. ValidateConfiguration Validate Configuration Validates the configuration of the object and returns an array of error strings. Control
[retval] Errors (Array of String) : An array of returned error strings.
So if there is nothing wrong with an objects configuration, then it should return nothing or an empty array.
**_Von: I should clarify: my subroutine exits as soon as this method gets called, when it still has a list of objects to loop through._**
AWoodland: Do you have any error handling set in your script (i.e. On Error Goto Something), it may be throwing a runtime error and redirecting you elsewhere.
bevanweiss: As Adam said, we need more information. If you can provide us a excerpt of your code it will help
**_Von: Thanks for the replies everyone. The code is real simple:_**
**_and I have a MSGBOX just before this line to ensure the object is correct._**
dmercer: I just tried this myself and got it to work. There is a folder called "Test script" which contains a DNP3 binary input called "New Binary Input Point". Below is the script.
_Public Function TestValidate Dim oErrorArray Dim oPoint Set oPoint = Server.FindObject("Test script.New Binary Input Point") If Not (oPoint Is Nothing) Then oErrorArray = oPoint.Interface.ValidateConfiguration End If End Function_
bevanweiss: Given that your sample code doesn't appear to show any looping... I suspect the problem is that you aren't performing any looping 😉
If you are expecting it to perform this action for each object in some list of objects you have, you will need to supply more code... like where you create that list of objects, and how you are looping through those objects.
oMyObject is a single DBObject object... if you are passing in a CGroup object then you should expect the ValidateConfiguration result to be incredibly boring... there's not much that can go wrong with CGroup configuration (apart from Redirection List stuff).
If you want to validate the configuration of every object within a CGroup instead... well then you need to do either iteration / recursion to visit each object and call this method explicitly on each.
dmercer: The sample code that I wrote was just to check the concept and to give Von something to compare to, because it sounds like something in his version is causing it to throw an error and terminate. I was just checking the result via the debugger.
**_Von: Also, I'm trying to perform this method on "broken" cdatasetrows ( If you go "Display Data" on these rows, a "Fail to get data" query error that can be fixed by re-saving this row) - too bad there is no error log to view for vbscript subroutines..._**
bevanweiss: Dean: I did mean the 'sample code' that Von supplied