Table of Contents

Example

Create/Replace Group (snippet)

by: Gregory Haynes, November 2018
published: http://forum.avolites.com/viewtopic.php?f=20&t=5938
description: snippet to store a group regardless whether it already exists or not
remarks:

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:

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.

functions

affected properties

control structures

Code

<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>

Explanation

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.

How to use it

Snippet only, to explain how the functions work.