|by:||Gregory Haynes, November 2018|
|description:||snippet to store a group regardless whether it already exists or not|
The idea was to use
Group.StoreGroupReplace(Handles.GetTitanIdFromHandle(…)) to record a group regardless whether it already exists or not, but this doesn't work.
There are distinct functions:
Group.StoreGroupstores the group (but would fail if it already exists)
Group.ReplaceGroupOnHandlereplaces (but won't if the groups does not exist)
I don't think there is a single function which would do both replacing and storing as in most cases the software will return an error if it cannot do exactly what you have asked rather than make an assumption. What you would probably have to do is determine yourself whether the group already exists and then call the correct function, you should be able to do this using the Group.CheckIfGroupExists function.
<step>Group.CheckIfGroupExists(999.0, "Group.Numeric.IsValid")</step> <step condition="Math.IsEqual(Group.Numeric.IsValid, True)">Group.ReplaceGroupOnHandle(userNumber:999)</step> <step condition="Math.IsEqual(Group.Numeric.IsValid, False)">Group.StoreGroup(userNumber:999)</step>
This explains the functional steps within the sequence. For all the other XML details please refer to Formats and syntax
This checks if a particular group already exists, and then calls the correct function to store or replace the group.
Snippet only, to explain how the functions work.