Questionnaires
iDynamics Warehouse includes the functionality of creating questionnaires associated to warehouse, sales, purchase, or transfer documents. This document is intended to help developers who are going to extend this functionality, or integrate it with the customer's Business Central, with examples and instructions on how to implement some of the most common customizations.
Modify the Questionnaire Assigned to a Document or Line
By default, iDynamics Warehouse will assign to each document or line the questionnaire that has been configured in the questionnaire assignment tables. However, you may want to condition the assignment to other parameters that have not been provided by default in iDynamics Warehouse.
The OnBeforeFindQuestionnaire event, issued by the IDPWHS Questionnaire Management codeunit, allows you to modify the questionnaire that is assigned by default to a document or line:
OnBeforeFindQuestionnaire(DocumentType, DocumentNo, LineNo, QuestionnaireType, QuestionnaireCode, Handled);
The parameters of the event are:
- DocumentType. The type of document to which the questionnaire is to be assigned.
- DocumentNo. The document number.
- LineNo. The line number, if the questionnaire is to be assigned to a line.
- QuestionnaireType. Indicates whether a questionnaire is being assigned to the header or to a line of the document.
- QuestionnaireCode. If the event is caught, you can indicate in this variable the questionnaire to be applied.
- Handled. If true, the questionnaire code specified in the previous variable will be assigned.
Validate by Code the Answers Submitted by Users
When users try to post a document from the mobile application, this action is performed in two steps: first all the data of readings and answers to questionnaires are sent, and once saved, the post action is called.
Being web services, each of these steps is executed in a separate transaction, which means that cancelling the registration will keep the data received in Business Central (this is intended to be able to solve any problems from Business Central itself).
If you want to validate the data entered by the user, we recommend doing so in the standard posting events of the documents themselves, or using the OnBeforePostFromDevice event, in case we want the validation to be performed only when the data is sent from the mobile application (the latter event will also be triggered in case of confirming the document without registering).
It is worth mentioning that, any error returned using the Error method in these events, will be shown to the user in the mobile application.
Process Answers
It can be interesting to take advantage of the values entered by the users and apply them to certain fields/records in Business Central, for example by transferring the values of the tracking answers to the corresponding lot information, or to any other document.
The answers are stored in the IDPWHS Questionnaire Answer table, and to get the answers of a document it will be necessary to filter by the Document Type, Document No. and Activity Type fields (if it is a warehouse activity).
The Document Line No. field allows us to also filter by the specific line of the document, in the case of line level questionnaires (the answers associated to the header are identified because this field contains a zero as value). You can also filter by "Lot No." or "Serial No." in case you want to obtain the particular information associated to a tracking number.
All answers have a visible description of the answer in the Answer text field, but the Numeric Value, Date Value and Time Value fields will also be filled in depending on the type of field configured. In addition, in the case of yes/no questions, the numeric field will contain a zero or a one depending on the selected option.
In case you want to apply the answers to the document or its lines, we recommend to treat them in the OnAfterProcessReadBuffer event. If you want to apply them to the entries/documents resulting from posting the document, the OnBeforeArchiveQuestionnairesAnswers event is executed once the document has already been posted, but before archiving its answers.