Group.StoreGroupReplace

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

Moderator: Moderators

User avatar
sideshowbond
Posts: 182
Joined: 18 Nov 2016, 20:58

Group.StoreGroupReplace

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

Group.StoreGroupReplace(Handles.GetTitanIdFromHandle("groupHandleUN=999"))
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
Gregory
Posts: 1300
Joined: 14 Dec 2007, 15:25
Location: London, United Kingdom
Contact:

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