Skip to content

Single-step Assistant

A single-step assistant is an assistant which consist of only one step.

Single-step Assistant

Figure 1 - Single-step Assistant

One basic difference between general assistant and single-step assistant is that, in a single-step assistant you can include customized commands.

Single-step Assistant as a Modal Assistant

A single-step assistant can be called within another assistant or page which will open it as a modal assistant (see figure 2). If the assistant needs to be terminated the X button or the Cancel button can be used.

Single-step Modal Assistant

Figure 2 - Single-step Modal Assistant

When a modal assistant is opened, it will open on top of the current page. This means you are still on the same page. You can exit from the assistant using the keyword exit.

If the command exits with a value, such as OK or CANCEL then the dialog will be closed. If you instead do an exit without a value then the dialog will stay open. Refer the below code sample to see how the exit keyword is used:


// Example code - Use of the exit keyword  
//-----------------------------------------  

command Ok for CloseJobVirtuals {  
   label = "OK";  
   mode = Global;  
   variable CloseJobStructureVar;  
     
   execute {  
      call CloseJob(Company, JobId, UserGroup) into CloseJobStructureVar;  
      if [VoucherNo = null or VoucherNo = 0] {  
         exit CANCEL;  
      }  
      assistant ReportAssistant(JobId, VoucherNo, IlVoucherNo) {  
         when OK {  
            exit OK;  
         }  
      }  
      exit OK;  
   }  
}  

command Cancel for CloseJobVirtuals {  
   execute {  
      exit CANCEL;  
   }  
}  

Note: It is not recommended to use navigate back in order to exit from a modal assistant. If you do a navigate back in the assistant you will not end up on the page it was launched from, but rather to the page before that, which is not the practical usage.

Variations

When to use

A single-step assistant can be used to gather specific data required for a process. For example, if the data required is to be used in different entities, then an assistant can be used. If the process needs several other factors to be calculated before the OK command, then the most suitable is the single-step assistant where custom commands can be used.

How to use

1. Define a Single-step Assistant

A single-step assistant is created the same way as a general assistant, with a small change. Instead of steps block, all controls are added to the singlestep block. See example below:


assistant SingleStepAssistant using AssistantDataSet {  
   label = "Single-step Assistant";  

   singlestep {  
      group CustomerInfo;  
      list OrderList;  
   }  

   command Ok;  
   command Cancel;  
}  

2. Add Custom Commands

Single-step assistant can have commands that you can specify in addition to the OK and Cancel commands, see example code below:


assistant SingleStepAssistant using AssistantDataSet {  
   label = "Single-step Assistant";  

   singlestep {  
      group CustomerInfo;  
      list OrderList;  
   }  

   command Ok;  
   command Cancel;  
   command CalculateNewCost;  
}  

command CalculateNewCost for AssistantDataSet {  
   label = "Calculate New Cost";  
   enabled = [true];  
   execute {  
      call CalculateCost(OrderIdList);  
      exit;  
   }  
}  

Limitations

When using single-step assistant as a modal assistant, it is recommended not to use a deep hierarchy of nested modals since it can cause User Interface issues.

Keywords

None.

Properties

None.

Example

Below is an example of a single-step assistant. Note, how a modal assistant is initiated within the single-step assistant's OK Command.


//Example code  
//------------  

assistant CloseJobVirtualAssistant for CloseJobVirtuals {  
   label = "Close Jobs";  
   input(Company, VoucherType, UserGroup);  
   output(VoucherNo, AccountingYear, AccountingPeriod);  

   singlestep {  
      group CloseJobWithAllLedgerGroup;  
      group VoucherInfoGroup;  
      group VoucherInfoGroup;  
   }  
   command Ok;  
   command Cancel;  
   command UpdateLedger;  
}  

command Ok for CloseJobVirtuals {  
   label = "OK";  
   mode = Global;  
   variable CloseJobStructureVar;  

   execute {  
      call CloseJob(Company, JobId, UserGroup) into CloseJobStructureVar;  
      set ValidUntilDate = CloseJobStructureVar.ValidDate;  
      set VoucherDate = CloseJobStructureVar.ValidDate;  
      set VoucherNo = CloseJobStructureVar.VoucherNo;  

      if [VoucherNo = null or VoucherNo = 0] {  
         set ReadyDate = CloseJobStructureVar.SysDate;  
      }  
      assistant ReportAssistant(JobId, VoucherNo, IlVoucherNo) {  
         when OK {  
            exit OK;  
         }  
      }  
      exit OK;  
   }  
}  

command Cancel for CloseJobVirtuals {  
   execute {  
      exit CANCEL;  
   }  
}  

command UpdateLedger for CloseJobVirtuals {  
   label = "Update Ledger";  
   enabled = [true];  
   execute {  
      call TransferAll(Objkey);  
      exit;  
   }  
}  

Example - Single-step Assistant initiating a Modal Assistant