No Longer needed

Kumaru
Giga Contributor

 

No Longer needed

2 REPLIES 2

Amit Verma
Kilo Patron
Kilo Patron

Hi @Kumaru 

 

Do you want to populate 'question:answer' as a choice or just 'answer' as choice ? Can you please elaborate on your requirement ?

 

Thanks & Regards
Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

@Kumaru 

 

Suppose I have a custom table 'u_question_and_answer' which stores all the Questions and the Answers.

 

AmitVerma_0-1710473849771.png

 

AmitVerma_4-1710474030271.png

 

Now If I want to get them as Key Value Pairs, I can make use of below script include :

 

var getChoices = Class.create();
getChoices.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getQuestionandAnswers:function(){
	var qaArray = [];
	var qaGR = new GlideRecord('u_question_and_answer');
	qaGR.query();
	while(qaGR.next()){
		qaArray.push((qaGR.u_question+':'+qaGR.u_answer).toString());
	}
	return qaArray.toString();

},
    type: 'getChoices'
});

 

AmitVerma_1-1710473914226.png

 

When called, this Script Include will give Q and A in the form of Key:Value Pairs.

 

AmitVerma_2-1710473975625.png

 

AmitVerma_3-1710473991143.png

 

You can use this response in your client script to populate the choices.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.