GroupBuilderRule class

From Catglobe Wiki
Revision as of 08:07, 19 April 2017 by Nguyenduyan (talk | contribs)
Jump to: navigation, search

GroupBuilderRule



Represents a group builder rule.

Constructors

  • (GroupBuilderRoot root "Associate with this root collections group") - Create a new rule

Methods

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.

Bug 1. Create variable type below -> get error (. root (( Save)) @ GroupBuilderCatiOutcomeVariable GroupBuilderParticipationPeriodVariable GroupBuilderProtectedUntilVariable GroupBuilderSampleRuleVariable GroupBuilderTemplateVariable

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


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();