This is a place for people to chare the custom macros they have written.

Moderator: Moderators

User avatar
Posts: 179
Joined: 18 Nov 2016, 20:58


Postby sideshowbond » 07 Nov 2018, 09:42

I am looking for a way to store a group with the following conditions:
Store the group if it doesn't exist
Replace the group if it already exists

I tried

Code: Select all

to replace Group 999 but that didn't work. In fact it didn't store anything. There is an exception in the logs but that doesn't prove very helpful.

I can get delete, store and replace to work to build a workaround but that's not quite ideal the way I have that in mind.
User avatar
Site Admin
Posts: 1171
Joined: 14 Dec 2007, 15:25
Location: London, United Kingdom

Re: Group.StoreGroupReplace

Postby Gregory » 13 Nov 2018, 00:54

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.

Try this:

Code: Select all

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

Who is online

Users browsing this forum: No registered users and 1 guest