Question T17482
Visible to All Users

Some unique ID for each question within the dynamic panel or matrix

created 10 months ago

Hi Team,
we are implemented custom widget that will add to each question , we are adding chat button widget by referring following link

https://codesandbox.io/p/sandbox/awesome-wilbur-ff5pfz?file=%2Fsrc%2FSurveyCreatorComponent.jsx%3A39%2C4

We are opening dialog on that chat button click , In the comment dialog we are making an API to get all the chats/threads added to that question by using the question's name. We are able to achieve this for all type of normal questions.

We are facing some challenges in case of nested panel or row level questions (template questions/columns) in Dynamic panel/Dynamic Matrix type of questions. Here since the panels & row are repeating we are not able to find out the exact question name since these are template driven questions & template gets repeated. We tried to use the panelIndex/rowIndex but that is also not going to be same always if we add or row anything from the Matrix or Panel.

We want to have some unique ID for each question within the dynamic panel or matrix which is going to be constant always so that we can use it for making the API call & also this ID needs to be stored in the database as a part of the response JSON.

Can you please help to solve this scenario.

Show previous comments (11)

    Hi Andrew,

    yes , I have already did this code , but I am facing issue with rebinding internal name to same question , when we open questionnaire again .

    we are implemented custom widget that will add to each question , we are adding chat button widget by referring following link
    https://codesandbox.io/p/sandbox/awesome-wilbur-ff5pfz?file=%2Fsrc%2FSurveyCreatorComponent.jsx%3A39%2C4
    We are opening dialog on that chat button click , In the comment dialog we are making an API to get all the chats/threads added to that question by using the question's name. We are able to achieve this for all type of normal questions.
    We are facing some challenges in case of nested panel or row level questions (template questions/columns) in Dynamic panel/Dynamic Matrix type of questions. Here since the panels & row are repeating we are not able to find out the exact question name since these are template driven questions & template gets repeated. We tried to use the panelIndex/rowIndex but that is also not going to be same always if we add or row anything from the Matrix or Panel.
    We want to have some unique ID for each question within the dynamic panel or matrix which is going to be constant always so that we can use it for making the API call & also this ID needs to be stored in the database as a part of the response JSON.

      Hello Nikhil,
      I am afraid, I am not fully understand the task. For a common questions, you can set a uniqueId at design-time in Creator. Ηοwever. it is not so easy for dynamic panel and dynamic matrix.
      There is a template panel in dynamic panel that has a unique names across the survey. Matrices have column names that are not unique across the survey, they are unique for a matrix.
      You can make make questions in dynamic panel unique by adding a panel index, for Matrices cells you can make them unique by using "matrix name" + "a divider" + "column name" + "row index",
      The problem that you can't set this Ids in design-time because panels and rows are created during run-time. Since I don't understand your task in detail, I can't suggest something.
      We can make a conference call with your product manager and tech. lead if you are really stuck. You can scheduler it from our contact page. There is a "Schedule a call" button on the bottom: https://surveyjs.io/contact-us

      Thank you,
      Andrew
      SurveyJS Team

        Hello Nikhil,
        I believe this example emulates the behavior you need.

        Thank you,
        Andrew
        SurveyJS Team