Difference between revisions of "GroupBuilderRule class"

From Catglobe Wiki
Jump to: navigation, search
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
{{CGscriptClass_Template
 
{{CGscriptClass_Template
|Name=GroupBuilderRule
+
|Name=<nowiki>GroupBuilderRule</nowiki>
|Description=Represents a group builder rule.
+
|Description=<nowiki>Represents a group builder rule.</nowiki>
|Constructors=
+
|InheritsFrom=object|Constructors=
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=GroupBuilderRoot|Name=root|Description=Associate with this root collections group}}
+
{{CGscriptParameters_Template|Type=GroupBuilderRoot|Name=<nowiki>root</nowiki>|Description=<nowiki>Associate with this root collections group</nowiki>}}
|Description=Create a new rule}}
+
|Description=<nowiki>Create a new rule</nowiki>}}
 
|Methods=
 
|Methods=
{{CGscriptMethods_Template|ReturnType=Empty|Name=Add|Parameters=
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Add</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=variable|Description=Variable to add}}
+
{{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=<nowiki>variable</nowiki>|Description=<nowiki>Variable to add</nowiki>}}
|Description=Add a new variable}}
+
|Description=<nowiki>Add a new variable</nowiki>}}
{{CGscriptMethods_Template|ReturnType=GroupBuilderVariable|Name=this[] { get; }|Parameters=
+
{{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>this[] { get; }</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=int|Name=index|Description=Index}}
+
{{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>}}
|Description=Get variable at index}}
+
|Description=<nowiki>Get variable at index</nowiki>}}
{{CGscriptMethods_Template|ReturnType=bool|Name=Remove|Parameters=
+
{{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Remove</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=variable|Description=Variable to remove}}
+
{{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=<nowiki>variable</nowiki>|Description=<nowiki>Variable to remove</nowiki>}}
|Description=Remove variable. Return true if removed}}
+
|Description=<nowiki>Remove variable. Return true if removed</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Empty|Name=this[] { set; }|Parameters=
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>this[] { set; }</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=int|Name=index|Description=Index|Comma=,}}{{CGscriptParameters_Template|Type=GroupBuilderVariable|Name=value|Description=Value to set}}
+
{{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to set</nowiki>}}
|Description=Set variable at index}}
+
|Description=<nowiki>Set variable at index</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=ToString|Description=The string representation of the object.}}
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 
|Properties=
 
|Properties=
{{CGscriptProperties_Template|ReturnType=int|Name=Actual|HasGetter=1|Description=How many of the final group amount was generated from this rule}}
+
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Actual</nowiki>|HasGetter=1|Description=<nowiki>How many of the final group amount was generated from this rule</nowiki>}}
{{CGscriptProperties_Template|ReturnType=GroupBuilderRuleCollection|Name=Children|HasGetter=1|Description=Child rules for this rule}}
+
{{CGscriptProperties_Template|ReturnType=GroupBuilderRuleCollection|Name=<nowiki>Children</nowiki>|HasGetter=1|Description=<nowiki>Child rules for this rule</nowiki>}}
{{CGscriptProperties_Template|ReturnType=int|Name=Count|HasGetter=1|Description=Number of variables at this level}}
+
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Count</nowiki>|HasGetter=1|Description=<nowiki>Number of variables at this level</nowiki>}}
{{CGscriptProperties_Template|ReturnType=bool|Name=IncludeDeleted|HasGetter=1|HasSetter=1|Description=Include deleted users or not}}
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IncludeDeleted</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Include deleted users or not</nowiki>}}
{{CGscriptProperties_Template|ReturnType=bool|Name=IncludeDisabled|HasGetter=1|HasSetter=1|Description=Include disabled users or not}}
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IncludeDisabled</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Include disabled users or not</nowiki>}}
{{CGscriptProperties_Template|ReturnType=bool|Name=IsLeaf|HasGetter=1|Description=True if this rule as no children}}
+
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IsLeaf</nowiki>|HasGetter=1|Description=<nowiki>True if this rule as no children</nowiki>}}
{{CGscriptProperties_Template|ReturnType=string|Name=Name|HasGetter=1|HasSetter=1|Description=Name of rule}}
+
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Name of rule</nowiki>}}
{{CGscriptProperties_Template|ReturnType=string|Name=ObjectTypeName|HasGetter=1|Description=The name of the type of object.}}
+
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=int|Name=Target|HasGetter=1|HasSetter=1|Description=Target amount to build for this group. -1 == all}}
+
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Target</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Target amount to build for this group. -1 == all</nowiki>}}
{{CGscriptProperties_Template|ReturnType=number|Name=TargetPct|HasGetter=1|HasSetter=1|Description=Target as pct of parent. -1 == use Target}}
+
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>TargetPct</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Target as pct of parent. -1 == use Target</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}}
+
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
 
}}
 
}}
Bug 1. Create variable type below -> get error (. root (( Save)) @
 
GroupBuilderCatiOutcomeVariable
 
GroupBuilderParticipationPeriodVariable
 
GroupBuilderProtectedUntilVariable
 
GroupBuilderSampleRuleVariable
 
GroupBuilderTemplateVariable
 
  
cgscript:
+
=== <span style="color:#DF8621">'''Examples'''</span> ===
GroupBuilderRoot root = new GroupBuilderRoot (15560405);
 
GroupBuilderCatiOutcomeVariable variable = new GroupBuilderCatiOutcomeVariable ();
 
//GroupBuilderParticipationPeriodVariable variable = new GroupBuilderParticipationPeriodVariable();
 
//GroupBuilderProtectedUntilVariable variable = new GroupBuilderProtectedUntilVariable();
 
//GroupBuilderSampleRuleVariable variable = new GroupBuilderSampleRuleVariable();
 
//GroupBuilderTemplateVariable variable = new GroupBuilderTemplateVariable(true);
 
GroupBuilderRule rule = new GroupBuilderRule (root);
 
rule.Add(variable);
 
GroupBuilderRuleCollection ruleColection = root.RootRules;
 
ruleColection.Add(rule);
 
root.Save();
 
 
 
=> Error when run the script: An exception 'Object reference not set to an instance of an object.' occured while calling (. root (( Save)) @
 
see image http://cghead.catglobe.com/Images/GetImage.aspx?rid=1ce5b169-acde-4317-8676-9b5afa81dac9
 
 
 
Bug 2.  Problem with Range on GroupBuilderNumberOfCallsVariable
 
 
 
cgscript:
 
GroupBuilderRoot root = new GroupBuilderRoot (15560798);
 
GroupBuilderNumberOfCallsVariable variable = new GroupBuilderNumberOfCallsVariable ();
 
variable.QuestionnaireResourceId = 15546533;
 
Range a = new Range ("[1-4,9,12]");
 
variable.Range = a;
 
GroupBuilderRule rule = new GroupBuilderRule (root);
 
rule.Add(variable);
 
GroupBuilderRuleCollection ruleColection = root.RootRules;
 
ruleColection.Add(rule);
 
root.Save();
 
 
 
==> cript run completed but can't save the variable on GUID because of wrong range format
 
see image http://cghead.catglobe.com/Images/GetImage.aspx?rid=b0d458b0-ac49-4e6e-a725-3d25f6217b5d
 
 
 
Bug 3. Error when Add qnaire on GroupBuilderUsageVariable
 
 
 
cgscript:
 
GroupBuilderRoot root = new GroupBuilderRoot (15560798);
 
GroupBuilderUsageVariable variable = new GroupBuilderUsageVariable ();
 
number qnaireRId  = 15546533;
 
bool includeTestUsers =false;
 
bool includeCompleted = false;
 
bool includePartlyCompleted = false;
 
bool includeNotStarted = true;
 
bool includeNotParticipated = false;
 
variable.Add(qnaireRId, includeTestUsers, includeCompleted, includePartlyCompleted, includeNotStarted, includeNotParticipated);
 
//variable.Add(15546533, false, false, false, true, false);
 
rule.Add(variable);
 
GroupBuilderRuleCollection ruleColection = root.RootRules;
 
ruleColection.Add(rule);
 
root.Save();
 
==> Error when run the script: No conditionas @
 
see image http://cghead.catglobe.com/Images/GetImage.aspx?rid=3eadd94e-1ad6-4ae8-9ad5-1332b8b45ad6
 
 
 
Bug 4. GroupBuilderUserInfomationVariable not fix
 
 
 
cgscript:
 
GroupBuilderRoot root = new GroupBuilderRoot (15560790);
 
GroupBuilderUserInfomationVariable  variable = new GroupBuilderUserInfomationVariable  ();
 
variable.QuestionnaireResourceId = 15546533;
 
variable.CountryIsoCode="dk";
 
variable.CultureIsoCode = "da-DK";
 
variable.LanguageIsoCode ="da-DK";
 
GroupBuilderRule rule = new GroupBuilderRule (root);
 
rule.Add(variable);
 
GroupBuilderRuleCollection ruleColection = root.RootRules;
 
ruleColection.Add(rule);
 
root.Save();
 
  
==> the script run completed but show empty on GUID
+
'''Example: Add new rule''' <source lang="javascript">
see image http://cghead.catglobe.com/Images/GetImage.aspx?rid=68d70bea-b835-4f18-94af-b51490ce473a
 
 
 
 
 
-------------------
 
 
 
GroupBuilderBulkSMSVariable failed
 
 
 
GroupBuilderRoot root = new GroupBuilderRoot (15560405);
 
GroupBuilderBulkSMSVariable variable = new GroupBuilderBulkSMSVariable ();
 
variable.BulkSMSResourceId = 15560817 ;
 
GroupBuilderRule rule = new GroupBuilderRule (root);
 
rule.Add(variable);
 
GroupBuilderRuleCollection ruleColection = root.RootRules;
 
ruleColection.Add(rule);
 
root.Save();
 
 
 
------------------
 
 
 
GroupBuilderBulkSMSHistoryVariable check mistake doc
 
-------------
 
 
 
----
 
GroupBuilderNumberOfCallsVariable problem with get Range
 
 
 
GroupBuilderRoot root = new GroupBuilderRoot (15560798);
 
GroupBuilderRuleCollection ruleColection = root.RootRules;
 
GroupBuilderNumberOfCallsVariable variable = ruleColection[0][0];
 
print(variable.Range);
 
------
 
GroupBuilderUsageVariable error on Document
 
----
 
=== <span style="color:#DF8621">'''Examples'''</span> ===
 
'''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].IncludeDeleted=true;
supRules[i].IncludeDisabled = true;
+
supRules[i].IncludeDisabled = true;
supRules[i].TargetPct=20;
+
supRules[i].TargetPct=20;
supRules[i].Name="subRule "+i;
+
supRules[i].Name="subRule "+i;
supRules[i].Add(variable);
+
supRules[i].Add(variable);
+
  
 
}
 
}
 
root.Save();
 
root.Save();
 
</source>
 
</source>

Latest revision as of 05:49, 2 July 2020

GroupBuilderRule



Represents a group builder rule.

Parent class

Inherits from object

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
  • object 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", object value "Value to set") - Set variable at index
  • (From object) 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
  • (From object) 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();