Difference between revisions of "QcsQuestionColumn class"
Line 27: | Line 27: | ||
=== '''Examples''' === | === '''Examples''' === | ||
− | ''' | + | '''Ex: Create question columns for Primary qnaire''' |
<source lang="javascript"> | <source lang="javascript"> | ||
Line 39: | Line 39: | ||
dcs.Save(); //Must save to make the above statements applied on DCS, but this statement does not REBUILD the DCS | dcs.Save(); //Must save to make the above statements applied on DCS, but this statement does not REBUILD the DCS | ||
print(dcs.ColumnNames); | print(dcs.ColumnNames); | ||
+ | </source> | ||
+ | |||
+ | '''Ex: Copy all question columns from DCS A to DCS B''' | ||
+ | <source lang="javascript"> | ||
+ | // Copy all question columns from DCS A to DCS B | ||
+ | number dcsARId = 15645155; | ||
+ | number dcsBRId = 15645157; | ||
+ | number qnaireARId = 15645137; | ||
+ | |||
+ | DataCacheSpecification dcsA = new DataCacheSpecification(dcsARId); | ||
+ | DataCacheSpecification dcsB = new DataCacheSpecification(dcsBRId); | ||
+ | |||
+ | dcsB.Reset(); | ||
+ | dcsB.ClearSecondaryQuestionnaireJoinType(); | ||
+ | dcsB.SetSecondaryQuestionnaireJoinType (qnaireARId,"CompanyNumber","CompanyNumber"); | ||
+ | array arrayQuestionColumns = dcsA.CreateAllColumnsForAllQuestions(0); | ||
+ | for(number i = 0; i<arrayQuestionColumns.Count; i++) | ||
+ | { | ||
+ | QcsQuestionColumn questionColumn = arrayQuestionColumns[i]; | ||
+ | questionColumn.ChangeDcs(dcsB); | ||
+ | questionColumn.Save(); | ||
+ | } | ||
+ | dcsB.Save(); | ||
+ | dcsB.Rebuild(true,true,0); | ||
</source> | </source> |
Revision as of 11:17, 25 April 2019
QcsQuestionColumn
Represents a data cache specification column with data from collected questions.
Methods
- Empty ChangeDcs(DataCacheSpecification dcs "New DCS to put the column in") - Change column to belong to another DCS. The origin DCS is not altered
- Empty Delete() - Remove column from the dcs
- Empty Save() - Add a new column to the dcs. Naming conflicts are automatically resolved. Notice the dcs itself also needs to be saved
- string ToString() - The string representation of the object.
Properties
- int AnswerOptionIndex { get; } - Get which answer option is used for this column. -1 if not from answer option.
- string CgScript { get; set; } - Get/set the cgscript for the column
- string ColumnType { get; } - Get the source type of the column data
- string DataType { get; } - Get the data type of the column
- string Name { get; set; } - Get/set the name of the column
- string ObjectTypeName { get; } - The name of the type of object.
- bool OpenPart { get; } - Get if this column is the open part of the question.
- bool PresentAsText { get; set; } - Get/set if Show the data column as the option text
- string QuestionLabel { get; } - Get the questionlabel used for getting data for this column.
- int QuestionnaireResourceId { get; } - Get the questionnaire used for getting data for this column.
- int SubQuestionIndex { get; } - Get which sub question is used for this column. -1 if not from subquestion.
- TypeInformation TypeInformation { get; } - Get information about this class.
Examples
Ex: Create question columns for Primary qnaire
DataCacheSpecification dcs = new DataCacheSpecification(15517146);
array aQcsQuestionColumns = dcs.CreateAllColumnsForQuestion("Q1",0); //Create new column(s) for a question and use primary questionnaire
for(number i= 0; i < aQcsQuestionColumns.Count; i++){
aQcsQuestionColumns[i].Save();
}
dcs.Save(); //Must save to make the above statements applied on DCS, but this statement does not REBUILD the DCS
print(dcs.ColumnNames);
Ex: Copy all question columns from DCS A to DCS B
// Copy all question columns from DCS A to DCS B
number dcsARId = 15645155;
number dcsBRId = 15645157;
number qnaireARId = 15645137;
DataCacheSpecification dcsA = new DataCacheSpecification(dcsARId);
DataCacheSpecification dcsB = new DataCacheSpecification(dcsBRId);
dcsB.Reset();
dcsB.ClearSecondaryQuestionnaireJoinType();
dcsB.SetSecondaryQuestionnaireJoinType (qnaireARId,"CompanyNumber","CompanyNumber");
array arrayQuestionColumns = dcsA.CreateAllColumnsForAllQuestions(0);
for(number i = 0; i<arrayQuestionColumns.Count; i++)
{
QcsQuestionColumn questionColumn = arrayQuestionColumns[i];
questionColumn.ChangeDcs(dcsB);
questionColumn.Save();
}
dcsB.Save();
dcsB.Rebuild(true,true,0);