Skip to Content
avatar image
Former Member

CRM DINAMIC SURVEY

Hi, All

     I need help with create the dynamic questionnaire. In transaction CRM_SURVEY_SUITE I have the own survey with a few questions. I want to hide/delete some questions depending on the answers of to previous questions. To do this, I created own FM Z*PBO (copy of CRM_MKTCA_SURVEY_MKT_PBO). To begin, I write a simple code to instantly hide some questions, starting with the third. I'am using method ir_survey_values->no_display_add in that FM:


     loop at lt_all_values into ls_all_values.

      

       if ls_all_values-question_id = zcl_crm_mkt_svz_survey=>c_qst2 and lv_excl_flag is initial.

              lv_excl_flag = 'X'.

              continue.

       elseif lv_excl_flag = 'X'.

        

          ls_no_display-name = ls_all_values-question_id.

          append ls_no_display to lt_no_display.

       else.

         continue.

       endif.

     endloop.

call method ir_survey_values->no_display_add

      exporting

        it_no_display = lt_no_display.


As a result, I hide the questions and their answers. But the texts(for example: Text of the sections of the survey, Text for the answers ) are displaying. Tell me please  detail - how to hide them too. Maybe I need to create the javascript code, which can hide/show questions or sections of the survey? Or something else?



I found the code that returns text. Maybe there is functionality that they can change this texts?


data lo_surv_texts type ref to cl_crm_svy_survey_texts.

   data lt_crm_text_t type crm_svy_api_survey_text_t.

   create object lo_surv_texts

     exporting

       i_application_id = i_application_id

       i_survey_id      = i_survey_id

       i_survey_version = i_survey_version

       i_language       = sy-langu

     exceptions

       survey_not_found = 1

       others           = 2.

   call method lo_surv_texts->get_all_texts

     importing

       et_texts = lt_crm_text_t.




Regards, Valeriy

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 28, 2015 at 12:45 AM

    Hi Valeriy,

    Have a look at the FM: CRM_SVY_EXAMPLE_DYNAMIC_PBO.

    It plays with survey elements using java script.

    Regards,

    Naresh

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Valeriy,

      I am not completely sure about this requirement.

      I think its possible with dynamic list box. You can have a look at the standard dynamic PBO FM. In last section of code, it shows how to play with dynamic list box.

      Regards,

      Naresh

  • avatar image
    Former Member
    Nov 12, 2015 at 09:38 AM

    Hello.

    Task completed.

    For to bind a function with the answer of the question, I used the event "onclick":

       ex_script-name     = 'answer2'.                           "#EC NOTEXT
       ex_script-language = 'JavaScript1.2'.                     "#EC NOTEXT
       ex_script-script   = 'function answer2() { '.


       concatenate ex_script-script

                    alert(''onclick!'');'

                   '}'

         into ex_script-script.


    append ls_javascript to lt_javascript.
       call method ir_survey_values->javascript_add
         exporting
           it_script = lt_javascript.


        clear ls_svy_on_event.
       ls_svy_on_event-question_id   = 'id_b748794d673ed77de10000000a781c65'.
       ls_svy_on_event-answer_id     = 'id_0050568601f81ed598ea87be3f400ab9'.
       ls_svy_on_event-name          = 'onclick'.          

       concatenate 'answer2' '()' into ls_svy_on_event-call_function.
       append ls_svy_on_event to lt_svy_on_event.

      

        call method ir_survey_values->on_event_add
         exporting
           it_on_event = lt_svy_on_event.

    Add comment
    10|10000 characters needed characters exceeded