Skip to content

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

  • With the dynamic keyword, define a function that returns the set-up procedure. This should be a structure of type FndDynamicAssistantSetUp.
  • Setting the autocomplete flag to true, the dynamic assistant will auto fill steps that have a default value, and carry on doing so until it reaches a step that doesn't.

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

  • This structure has 3 attributes that you may provide procedure names as text.
    • InitMetaFunction - return the list of initialization commands
    • StepsMetaFunction - return the list of steps
    • FinishMetaFunction - return the list of finish commands
  • Steps should be returned from a procedure as a list of FndDynamicAssistantStep structures.
  • The SaveAction attribute of a step should point to a procedure that gets called when the step is completed. This procedure should return a structure of type FndDynamicNextStep which should give information about what the next step should be.
  • Commands should be returned as a list of FndDynamicCommandDef structures to be used during init/finish. Currently ‘set’, ‘alert’ and ‘action’ are supported.

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

Limitations

  • Same limitations for standard assistants apply.
  • The user cannot finish the dynamic assistant mid-way. A workaround is that the developers provide a terminating question.

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

  • init
  • finish command
  • cancel command
  • label
  • savemode
  • steps
  • autocomplete

Supported Steps

  • dynamic
  • final step
  • cancelled step

Offline file supported properties

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

In FndDynamicAssistSetup:

  • ResumeSupported (Boolean)

In FndDynamicAssistStep structure:

  • DynamicLovMaxSelectableOptions (Number)
  • DefaultValueAction (Text)
  • DefaultValueActionParameters (Text)

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:

  • When defining the FndDynamicAssistSetup structure, set the ResumeSupported property to true and the StartStep property to any step number from which the assistant should resume from.
  • In the function where assistant steps are defined, FndDynamicAssistStep set the DefaultValueAction to the name of the function/action that will return the value to be shown in this step when the assistant resumes from a step after it. The DefaultValueActionParameters property allows passing parameters when calling the above function.

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;  
   }  
}