Difference between revisions of "GroupBuilderRule class"
Nguyenduyan (talk | contribs) |
Nguyenduyan (talk | contribs) |
||
Line 33: | Line 33: | ||
{{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 new rule''' <source lang="javascript"> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | '''Example: Add new rule''' | ||
− | <source lang="javascript"> | ||
//Create a new group | //Create a new group | ||
string groupName = "Test Group Builder: GroupBuilderRule"; | string groupName = "Test Group Builder: GroupBuilderRule"; | ||
Line 166: | Line 60: | ||
</source> | </source> | ||
<br/> | <br/> | ||
− | '''Example: Add variable for rule''' | + | '''Example: Add variable for rule''' |
<source lang="javascript"> | <source lang="javascript"> | ||
GroupBuilderRoot root = new GroupBuilderRoot (15560828); | GroupBuilderRoot root = new GroupBuilderRoot (15560828); | ||
Line 181: | Line 75: | ||
<br/> | <br/> | ||
'''Example: remove variable''' | '''Example: remove variable''' | ||
− | <source lang="javascript"> | + | <source lang="javascript"> |
GroupBuilderRoot root = new GroupBuilderRoot (15560828); | GroupBuilderRoot root = new GroupBuilderRoot (15560828); | ||
GroupBuilderRuleCollection ruleColection = root.RootRules; | GroupBuilderRuleCollection ruleColection = root.RootRules; | ||
Line 190: | Line 84: | ||
</source> | </source> | ||
<br/> | <br/> | ||
− | '''Example: Add children rule''' | + | '''Example: Add children rule''' |
− | <source lang="javascript"> | + | <source lang="javascript"> |
GroupBuilderRoot root = new GroupBuilderRoot (15560828); | GroupBuilderRoot root = new GroupBuilderRoot (15560828); | ||
GroupBuilderRuleCollection rootRules = root.RootRules; | GroupBuilderRuleCollection rootRules = root.RootRules; | ||
Line 203: | Line 97: | ||
for (number i=0;i<supRules.Count;i++) | for (number i=0;i<supRules.Count;i++) | ||
{ | { | ||
− | + | supRules[i].IncludeDeleted=true; | |
− | + | supRules[i].IncludeDisabled = true; | |
− | + | supRules[i].TargetPct=20; | |
− | + | supRules[i].Name="subRule "+i; | |
− | + | supRules[i].Add(variable); | |
− | + | ||
} | } | ||
root.Save(); | root.Save(); | ||
</source> | </source> |
Revision as of 08:09, 19 April 2017
GroupBuilderRule
Represents a group builder rule.
Constructors
- (GroupBuilderRoot root "Associate with this root collections group") - Create a new rule
Methods
- Empty Add(GroupBuilderVariable variable "Variable to add") - Add a new variable
- GroupBuilderVariable this[] { get; }(int index "Index") - Get variable at index
- bool Remove(GroupBuilderVariable variable "Variable to remove") - Remove variable. Return true if removed
- Empty this[] { set; }(int index "Index", GroupBuilderVariable value "Value to set") - Set variable at index
- string ToString() - The string representation of the object.
Properties
- int Actual { get; } - How many of the final group amount was generated from this rule
- GroupBuilderRuleCollection Children { get; } - Child rules for this rule
- int Count { get; } - Number of variables at this level
- bool IncludeDeleted { get; set; } - Include deleted users or not
- bool IncludeDisabled { get; set; } - Include disabled users or not
- bool IsLeaf { get; } - True if this rule as no children
- string Name { get; set; } - Name of rule
- string ObjectTypeName { get; } - The name of the type of object.
- int Target { get; set; } - Target amount to build for this group. -1 == all
- number TargetPct { get; set; } - Target as pct of parent. -1 == use Target
- TypeInformation TypeInformation { get; } - Get information about this class.
Examples
Example: Add new rule
//Create a new group
string groupName = "Test Group Builder: GroupBuilderRule";
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);
GroupBuilderRule rule = new GroupBuilderRule (root);
rule.Name = "Main rule";
print(rule.Actual);
print(rule.Count);
print(rule.IsLeaf);
print(rule.Name);
rule.IncludeDeleted = true;
rule.IncludeDisabled = true;
rule.Target=100;
GroupBuilderRuleCollection ruleColection = root.RootRules;
ruleColection.Add(rule);
root.Save();
Example: Add variable for rule
GroupBuilderRoot root = new GroupBuilderRoot (15560828);
GroupBuilderRuleCollection ruleColection = root.RootRules;
GroupBuilderRule rule = ruleColection[0];
GroupBuilderOptionDataVariable variable1 = new GroupBuilderOptionDataVariable();
GroupBuilderGroupVariable variable2 = new GroupBuilderGroupVariable (true);
GroupBuilderBulkmailVariable variable3 = new GroupBuilderBulkmailVariable ();
rule.Add(variable1);
rule.Add(variable2);
rule.Add(variable3);
root.Save();
Example: remove variable
GroupBuilderRoot root = new GroupBuilderRoot (15560828);
GroupBuilderRuleCollection ruleColection = root.RootRules;
GroupBuilderRule rule = ruleColection[0];
GroupBuilderOptionDataVariable variable1 = rule[0];
rule.Remove(variable1);
root.Save();
Example: Add children rule
GroupBuilderRoot root = new GroupBuilderRoot (15560828);
GroupBuilderRuleCollection rootRules = root.RootRules;
GroupBuilderRule rootRule = rootRules[0];
GroupBuilderRuleCollection supRules = rootRule.Children;
GroupBuilderRule supRule1 = new GroupBuilderRule (root);
supRules.Add(supRule1);
GroupBuilderRule supRule2 = new GroupBuilderRule (root);
supRules.Add(supRule2);
GroupBuilderGroupVariable variable = new GroupBuilderGroupVariable (true);
for (number i=0;i<supRules.Count;i++)
{
supRules[i].IncludeDeleted=true;
supRules[i].IncludeDisabled = true;
supRules[i].TargetPct=20;
supRules[i].Name="subRule "+i;
supRules[i].Add(variable);
}
root.Save();