Dynamic Assistants

As opposed to standard assistants, the dynamic nature allows for defining the steps using procedures. The steps must be defined as structures and a method can be set which will be executed when saving a given step.

assistant DemoDynamicAssistant for SurveyAnswer {
   label = "Demo Dynamic Assistant";
   savemode = OnFinish;
   autocomplete = true;

   init command {
      execute {
         alert("Assistant Initialize");
      }
   }

   steps {
      dynamic SetUpDemo("TEST");

      final step {
         description = "Thank you";

         commandgroup Group1 {
            command AssistantCommandAccept;
            command AssistantCommandReject;
         }

         command AssistantCommandEmail;
      }

      cancelled step {
         description = "*Sad trombone*";

         markdowntext {
            text = "The assistant has been  canceled";
         }
      }
   }

   finish command {
      execute {
         alert("Assistant Finished");
      }
   }
}

Usage

The only exception to this is the final step. autocomplete will not automate this step.

Please refer to the Aurena developer guide for dynamic assistants for the full list of supported attributes and their explanations.

Limitations

Finish Command customization

In the finish command there are options for a customizable icon, label and finish message, and can be used as follows

finish command {
    label = "Click to Finish";
    icon = "calculator";
    message = "Are you sure that this is what you want to do?";

    execute {
    ...
    }
}

Supported Assistant Properties

Supported Steps

Offline file supported properties

As well as the properties above, the following properties are possible in the .offline file for dynamic assistants:

In FndDynamicAssistSetup:

In FndDynamicAssistStep structure:

Dynamic LoV Maximum Selectable Options

Limit the amount of choices in an LoV in a Dynamic Assistant. Eg, only allow the user to select 2 answers. The offline code would look like:

      create Step;
      set Step.Label = "Sample question 11";
      set Step.Description = "What type of programming languages are you interested in?";
      set Step.Name = "Question11";
      set Step.Visible = true;
      set Step.Enabled = true;
      set Step.ControlType = "checkBoxGroup";
      set Step.DynamicLovOptions = "A:C++,B:C#,C:Java,D:Perl,E:Javascript,F:Swift";
      set Step.DynamicLovMaxSelectableOptions = 2;
      set Step.Datatype = "Multichoice";
      set Step.Entity = "SurveyAnswer";
      set Step.BindAttribute = "Answer";
      set Step.SaveAction = "SaveDemoStep";
      set Step.SaveActionParameters = ["QuestionId:11,SurveyId:TEST,Answer:${Answer}"];
      set Step.DefaultValue = "Answer:[B,C]";

      call List.Add(Result, Step);

With the DynamicLovMaxSelectableOptions property being the property that limits the maximum options to 2 in this instance.

Resuming dynamic assistants

Optionally, a dynamic assistant may be configured to resume from a given step. The difference in this functionality when compared to only setting the StartStep property in the FndDynamicAssistSetup or from the component state is that this will load all previous steps with an answer pre-populated in them if needed.

How to set up resuming:

Notes: - The start step cannot be 0, 1 or the last step number. If the start step specified is disabled or invisible, then the assistant will resume from the next step which is enabled and visible. - The notation to be used when passing parameters should be similar to how SaveActionParameters are defined. Example: "SurveyId:TEST,QuestionId:4" - The function defined as DefaultValueAction should return the default value in the same format as specifiying the DefaultValue. Example: "Answer:TEST" (without quotes)

Example:

@Overtake Core
procedure Function<GenerateResumableAssistant> Structure(FndDynamicAssistSetup) {
   parameter Dummy Text;
   variable Result Structure(FndDynamicAssistSetup);
   ...
   execute {
      ...
      create Result;
      ...
      set Result.ResumeSupported = true;
      set Result.StartStep = 5;
      ...
      return Result;
   }
}

@Overtake Core
procedure Function<GetResumableAssistantSteps> List<Structure(FndDynamicAssistStep)> {
   variable Result List<Structure(FndDynamicAssistStep)>;
   variable Step Structure(FndDynamicAssistStep);

   execute {
      ...
      create Step;
      ...
      set Step.DefaultValueAction = "GetDefaultValueForStep";
      set Step.DefaultValueActionParameters = "QuestionId:1";
      ...
   }
}

@Overtake Core
procedure Function<GetDefaultValueForStep> Text {
   parameter QuestionId Number;

   variable SurveyAnswerRec Structure(TstSurveyAnswer);

   execute {
      fetch SurveyAnswers where [Answer != null and AnswerId = QuestionId] into SurveyAnswerRec;

      if [SurveyAnswerRec != null] {
         return ["Answer:"+SurveyAnswerRec.Answer];
      }

      return null;
   }
}