Create a rule programmatically

Hello,

How do I create a Rule programmatically? I know that the SDK does not support it (see https://developer.milestonesys.com/s/question/0D53X00005upioUSAQ/2019-r2-sdk-config-api-additions-can-we-now-create-record-rules).

Looking at the database ([Surveillance].[dbo].[Rules]) we see the column Definition is plain XML like this:

f07ac0e3-9662-4781-9176-ec9e488aa494

<Region name="VideoOS.Always">

 <Token type="Value" datatype="Boolean">True</Token>

</Region>
<Parameter name="State">On</Parameter>

<Parameter name="DeviceIds" />

<Parameter name="DeviceGroupIds">0e1b0ad3-f67c-4d5f-b792-4bd6c3cf52f8</Parameter>

<Parameter name="Delay">0</Parameter>

f07ac0e3-9662-4781-9176-ec9e488aa494

<Parameter name="State">Off</Parameter>

<Parameter name="DeviceIds" />

<Parameter name="DeviceGroupIds">0e1b0ad3-f67c-4d5f-b792-4bd6c3cf52f8</Parameter>

<Parameter name="Delay">0</Parameter>

This looks fairly easy to generate, basically we simply need to find all the GUIDs then insert a new entry in the table?

Please advice if there’s a better way.

We do not recommend making changes in the SQL configuration database. The database is undocumented and using it directly is not supported. The database is subject to change without notice from version to version. If the database is crippled in anyway by a change you can render the whole XProtect system dysfunctional.

Good news for you, Milestone is now working on the Configuration API, so the support for rule configuration will be in 2020 R1(limited version) or 2020 R2(close to full support). These plans can be changed so please follow Milestones communication on product road-map and new features.

Thanks for the answer. Where can I follow Milestones communication on product road-map and new features? The closest I found is https://releases.milestonesys.com/ and https://www.milestonesys.com/news/newsroom/press-releases/ but it’s lacking “future” releases.

Please sign up - https://www.milestonesys.com/news/newsroom/sign-up-for-news/

You may receive future information.

Thanks.