Create a offline form to add questions from existing Questionnarie template

RekhaG
Tera Contributor

Hi Folks,

I am trying to create a offline form by clicking on a UI Action, new offline form should open with questionnaire template from assessment metric table. User can able to answer these questions.

some one can help me with this--Thanks!

2 REPLIES 2

Samaksh Wani
Giga Sage
Giga Sage

1. Create Custom Tables

A. u_offline_questionnaire (Parent record)

  • Fields:

    • Requested By (reference to sys_user)

    • Created Date

    • Status (e.g., Draft, Submitted)

B. u_offline_question (Child record)

  • Fields:

    • Questionnaire (reference to u_offline_questionnaire)

    • Metric (reference to asmt_metric)

    • Question Text

    • Answer (string, choice, or reference based on metric type)

 

Link via one-to-many relationship between u_offline_questionnaire and u_offline_question.

 

 

Create a UI Action Server Side Code :-

 

// UI Action on a record or menu

// Create new questionnaire
var questionnaire = new GlideRecord('u_offline_questionnaire');
questionnaire.initialize();
questionnaire.requested_by = gs.getUserID();
questionnaire.status = 'draft';
questionnaire.insert();

// Fetch metrics from template
var metrics = new GlideRecord('asmt_metric');
metrics.addQuery('metric_type', 'questionnaire');
metrics.query();

while (metrics.next()) {
    var question = new GlideRecord('u_offline_question');
    question.initialize();
    question.questionnaire = questionnaire.sys_id;
    question.metric = metrics.sys_id;
    question.question_text = metrics.getValue('question');
    question.insert();
}

action.setRedirectURL(questionnaire);

 

3. Design the Questionnaire Form

  • On the u_offline_questionnaire form:

    • Add a related list or embedded list for u_offline_question

    • Allow users to edit the Answer field for each question

 

Pls mark my solution as accept and thumbs up if you find it helpful. It will help other users on community to find helpful response.

 

Regards,

Samaksh Wani

offline form has to load existing questionnaire template questions to answer directly. when click on the ui action