Difference between revisions of "GroupBuilderGroupVariable class"
Nguyenduyan (talk | contribs) (Created page with "{{CGscriptClass_Template |Name=GroupBuilderGroupVariable |Description=Represents a group builder variable for group membership. |Constructors= {{CGscriptConstructors_Template|...") |
Nguyenduyan (talk | contribs) |
||
Line 23: | Line 23: | ||
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | ||
}} | }} | ||
+ | |||
+ | === <span style="color:#DF8621">'''Examples'''</span> === | ||
+ | |||
+ | '''Example: Add group variable''' <source lang="javascript"> | ||
+ | //Create a new group | ||
+ | string groupName = "Test Group Builder: groupVariable"; | ||
+ | number groupTemplateResourceId=2066; | ||
+ | number parentResourceId = 11088827; | ||
+ | array group = Group_new(groupName, groupTemplateResourceId, parentResourceId); | ||
+ | Group_save(group); | ||
+ | number groupRId = group[GROUP_RESOURCE_ID ]; | ||
+ | |||
+ | //Create rule for the group | ||
+ | GroupBuilderRoot root = new GroupBuilderRoot (groupRId); | ||
+ | |||
+ | GroupBuilderGroupVariable groupVariable = new GroupBuilderGroupVariable (true);//true: include; false: exclude | ||
+ | groupVariable.Add(15547043);// 15547043: resourceId of group want to add to | ||
+ | groupVariable.Add(15085949);// 15085949: resourceId of group want to add to | ||
+ | |||
+ | GroupBuilderRule rule = new GroupBuilderRule (root); | ||
+ | rule.Add(groupVariable); | ||
+ | |||
+ | GroupBuilderRuleCollection ruleColection = root.RootRules; | ||
+ | ruleColection.Add(rule); | ||
+ | |||
+ | root.Save(); | ||
+ | |||
+ | //Rebuild group | ||
+ | Group_rebuildGroup(groupRId,true); | ||
+ | </source><br/>'''Example: Remove group variable''' <source lang="javascript"> | ||
+ | number groupRId = 15560550; | ||
+ | |||
+ | GroupBuilderRoot root = new GroupBuilderRoot (groupRId); | ||
+ | |||
+ | GroupBuilderRuleCollection ruleColection = root.RootRules; | ||
+ | GroupBuilderRule rule = ruleColection[0]; | ||
+ | GroupBuilderGroupVariable groupVariable = rule[0]; | ||
+ | groupVariable.Remove(15085949); | ||
+ | |||
+ | root.Save(); | ||
+ | </source> |
Revision as of 05:54, 30 March 2017
GroupBuilderGroupVariable
Represents a group builder variable for group membership.
Constructors
- (bool include "Include users, or if false exclude users") - Create new variable
Methods
- Empty Add(int groupResourceId "Group resource id to add") - Add a new group
- int this[] { get; }(int index "Index") - Get group resource id at index
- bool Remove(int groupResourceId "Group resource id to remove") - Remove group. Return true if removed
- string ToString() - The string representation of the object.
Properties
- int Count { get; } - Number of groups
- bool Include { get; } - Include users that match rule, or exclude
- string ObjectTypeName { get; } - The name of the type of object.
- TypeInformation TypeInformation { get; } - Get information about this class.
Examples
Example: Add group variable
//Create a new group
string groupName = "Test Group Builder: groupVariable";
number groupTemplateResourceId=2066;
number parentResourceId = 11088827;
array group = Group_new(groupName, groupTemplateResourceId, parentResourceId);
Group_save(group);
number groupRId = group[GROUP_RESOURCE_ID ];
//Create rule for the group
GroupBuilderRoot root = new GroupBuilderRoot (groupRId);
GroupBuilderGroupVariable groupVariable = new GroupBuilderGroupVariable (true);//true: include; false: exclude
groupVariable.Add(15547043);// 15547043: resourceId of group want to add to
groupVariable.Add(15085949);// 15085949: resourceId of group want to add to
GroupBuilderRule rule = new GroupBuilderRule (root);
rule.Add(groupVariable);
GroupBuilderRuleCollection ruleColection = root.RootRules;
ruleColection.Add(rule);
root.Save();
//Rebuild group
Group_rebuildGroup(groupRId,true);
Example: Remove group variable
number groupRId = 15560550;
GroupBuilderRoot root = new GroupBuilderRoot (groupRId);
GroupBuilderRuleCollection ruleColection = root.RootRules;
GroupBuilderRule rule = ruleColection[0];
GroupBuilderGroupVariable groupVariable = rule[0];
groupVariable.Remove(15085949);
root.Save();