Foros de discusión
Adding PollsQuestion programmatically
Nilesh Nemichand Gundecha, modificado hace 13 años.
Adding PollsQuestion programmatically
Regular Member Mensajes: 205 Fecha de incorporación: 1/12/09 Mensajes recientes
Hi Friends,
I am struggling to add one simple PollsQuestion along with 2 choices.
I tried to do below for same -
Now here I come and stuck up at creating List<PollsChoice> object. I checked PollsChoiceLocalServiceUtil class, but for creating/adding PollsChoice you again need wither questionId or PollsQuestion object.
Cant make out what I am missing. Please help.
Regards,
Nilesh.
I am struggling to add one simple PollsQuestion along with 2 choices.
I tried to do below for same -
Map<locale, string> titleMap = new HashMap<locale, string>();
titleMap.put(request.getLocale(), "Idea Polls");
Map<locale, string> descriptionMap = new HashMap<locale, string>();
descriptionMap.put(request.getLocale(), "Do you like this Idea");
Calendar cal = Calendar.getInstance();
long pollQuestionId = PollsQuestionLocalServiceUtil.addQuestion(ideatorId, titleMap , descriptionMap, cal.get(2), cal.get(5), cal.get(1), cal.get(11), cal.get(12), true, [color=#D41313]choices[/color], serviceContext);
</locale,></locale,></locale,></locale,>
Now here I come and stuck up at creating List<PollsChoice> object. I checked PollsChoiceLocalServiceUtil class, but for creating/adding PollsChoice you again need wither questionId or PollsQuestion object.
Cant make out what I am missing. Please help.
Regards,
Nilesh.
Himanshu Bhandari, modificado hace 8 años.
RE: Adding PollsQuestion programmatically
Regular Member Mensajes: 148 Fecha de incorporación: 9/05/14 Mensajes recientes
Hi
Polls choice is related to Question, so questionId is required to relate them. When you create a new question by passing it an ID, you need to pass the same ID to the choices while creating them.
Thanks.
but for creating/adding PollsChoice you again need wither questionId or PollsQuestion object.
Polls choice is related to Question, so questionId is required to relate them. When you create a new question by passing it an ID, you need to pass the same ID to the choices while creating them.
Thanks.