Difference between revisions of "QuestionnaireBatchJob class"
(2 intermediate revisions by the same user not shown) | |||
Line 32: | Line 32: | ||
[[File:2025-01-06_12-24-11.jpg]] | [[File:2025-01-06_12-24-11.jpg]] | ||
− | After support new Workflow prompt | + | After support new Workflow prompt, to run batch script: |
+ | * Simply open the Workflow prompt in Qnaire as normal: a default script will be displayed to guide how to use QuestionnaireBatchJob class | ||
+ | * Then, input your script | ||
+ | * And, click Execute to run it | ||
[[File:2025-01-06_13-54-36.jpg]] | [[File:2025-01-06_13-54-36.jpg]] | ||
Line 46: | Line 49: | ||
batch.Execute(function(Question Q100_Relation_New, Question Q6_Awareness){ | batch.Execute(function(Question Q100_Relation_New, Question Q6_Awareness){ | ||
QAS qas = new QAS(batch.CurrentId); | QAS qas = new QAS(batch.CurrentId); | ||
− | if(qas.Status == 5 | + | if(qas.Status == 5){ |
− | + | if(Q100_Relation_New[5] == empty && Q6_Awareness == [34]){ | |
+ | errorQAS.Add(batch.CurrentId); | ||
+ | } | ||
} | } | ||
}); | }); |
Latest revision as of 08:53, 6 January 2025
QuestionnaireBatchJob
Process each QAS with some custom logic in a optimal way.
Parent class
Inherits from object
Constructors
- (int questionnaireId "Id of the base questionnaire") - Process each QAS with some custom logic in a optimal way.
Methods
- Empty AttachQuestionnaire(int questionnaireId "Id of the questionnaire", bool latestOnly "If user has multiple qas, only include last created or error", bool completedOnly "Limit by qas that is completed", string questionLabel "Label of the question to load") - Load readonly question from another questionnaire based on UserId
- Empty AttachQuestionnaire(int questionnaireId "Id of the questionnaire", bool latestOnly "If user has multiple qas, only include last created or error", bool completedOnly "Limit by qas that is completed", string questionLabel "Label of the question to load", string alias "Alias to use in execute parameter naming") - Load readonly question from another questionnaire based on UserId with an alias
- Empty Execute(Function runner "The function called for each QAS - parameter names infers which questions to load") - Run the batch job - implicitly saves all modified question data
- (From object) string ToString() - The string representation of the object.
Properties
- bool CompletedOnly { get; set; } - Get/Set Limit by qas that is completed. Default true
- bool CurrentCompleted { get; set; } - Get/Set current qas to completed or not
- int CurrentId { get; } - Get current qas id
- bool CurrentIsTest { get; } - Get current qas is test qas
- bool IncludeTest { get; set; } - Get/Set if include test qas. Default false
- bool LatestOnly { get; set; } - Get/Set If user has multiple qas, only include last created or all. Default false
- string ObjectTypeName { get; } - The name of the type of object.
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
Examples
For instance, we have the cgscript, run in batch mode before, like this:
After support new Workflow prompt, to run batch script:
- Simply open the Workflow prompt in Qnaire as normal: a default script will be displayed to guide how to use QuestionnaireBatchJob class
- Then, input your script
- And, click Execute to run it
So, the script run batch script before should be updated to use QuestionnaireBatchJob class, looks like this:
QuestionnaireBatchJob batch = new QuestionnaireBatchJob(0);
//batch.LatestOnly = false;
//batch.CompletedOnly = true;
//batch.IncludeTest = false;
array errorQAS;
batch.Execute(function(Question Q100_Relation_New, Question Q6_Awareness){
QAS qas = new QAS(batch.CurrentId);
if(qas.Status == 5){
if(Q100_Relation_New[5] == empty && Q6_Awareness == [34]){
errorQAS.Add(batch.CurrentId);
}
}
});
print(errorQAS.Count);
print(errorQAS);