How to auto-populate survey results in a custom table fields ?

Navneet Arora
Mega Expert

Hi ,

I have a requirement to have input values in a survey from a user and when the survey is submitted then automatically store all values of questions in survey to a custom table in our instance. I think it can be be achieved through Business Rules. 

The objective is to use that custom table for further reporting and other purpose.

Please suggest the steps.

 

Regards,

Navneet Arora

1 ACCEPTED SOLUTION

Chander Bhusha1
Tera Guru

Hi Navneet,

Once the survey is created then a record is created that is Assessment Instance(asmt_assessment_instance) and when we complete the survey then its state changes to Complete. And in the asmt_metric_result table stores the answers and the question which are filled in the assessment.

So First of all you have to create differnce fields which will store the question and we will update the answers to the fields ( fields are question which are asked in the assement).

Steps:

1. Write an after Update BR on the assessment instance table when the state changes to closed then check the values of assessment instance with the asmt_metric_result table. So it will give you 5 records( say   questions were there in the assessment) 

So you have to take the answers from the value field and update in the custom table based on the metric(question).

 

Thanks,

CB

View solution in original post

3 REPLIES 3

Chander Bhusha1
Tera Guru

Hi Navneet,

Once the survey is created then a record is created that is Assessment Instance(asmt_assessment_instance) and when we complete the survey then its state changes to Complete. And in the asmt_metric_result table stores the answers and the question which are filled in the assessment.

So First of all you have to create differnce fields which will store the question and we will update the answers to the fields ( fields are question which are asked in the assement).

Steps:

1. Write an after Update BR on the assessment instance table when the state changes to closed then check the values of assessment instance with the asmt_metric_result table. So it will give you 5 records( say   questions were there in the assessment) 

So you have to take the answers from the value field and update in the custom table based on the metric(question).

 

Thanks,

CB

Navneet Arora
Mega Expert

Thanks CB

Hello Navneet 

i have similar requirement. I am using below code.

var assetname ;
var stakeholder ;
var payable ;
var waiver ;
var recovery ;
var gemetric = new GlideRecord('asmt_metric_result');
gemetric.addQuery('instance', current.sys_id);
gemetric.query();
while (gemetric.next()) {
if (gemetric.metric.name == 'Asset Name') {
assetname = gemetric.string_value;

} else if (gemetric.metric.name == 'Stakeholder Name') {
stakeholder = gemetric.string_value;

} else if (gemetric.metric.name == 'Payable Amount') {
payable = gemetric.string_value;

} else if (gemetric.metric.name == 'Waived Amount') {
waiver = gemetric.string_value;

} else if (gemetric.metric.name == 'Recovery Amount') {
recovery = gemetric.string_value;

}

}

var grseparation = new GlideRecord('sn_hr_core_ele_separation_metrics');
grseparation.initialize();
grseparation.u_stakeholder_name = stakeholder;
grseparation.u_asset_name = assetname;
grseparation.u_waived_amount = waiver;
grseparation.u_recovery_amount = recovery;
grseparation.u_payable_amount = payable;
grseparation.insert();

 

Is there any better way to do this?