UI action server-side script to generate survey

Varun Sareen
Tera Contributor

I am not able to generate a survey using the below ui action server-side script. The UI action needs to be created on the cmdb_ci_business_app table. Please advice for any corrections.

var typeSysID = 'c1d2fef9dbe3a5909cbf198d139619be';//The sys_id of the metric type or survey definition to generate assessments or surveys for.

var sourceRecordID = ''; 

var userID = current.getFieldValue('it_application_owner').sys_id; //The sys_id of the user in the cmdb_ci_business_app table and who is the survey respondent.

var result = new SNC.AssessmentCreation().createAssessments(typeSysID, sourceRecordID, userID);

var asmtGR = new GlideRecord("asmt_assessment_instance");

asmtGR.get(result.split(",")[0]);

asmtGR.setValue('trigger_table','cmdb_ci_business_app');

asmtGR.update();

 

1 ACCEPTED SOLUTION

Prateek kumar
Mega Sage

How about below:

var typeSysID = 'c1d2fef9dbe3a5909cbf198d139619be';//The sys_id of the metric type or survey definition to generate assessments or surveys for.

var sourceRecordID = ''; 

var userID = current.it_application_owner//The sys_id of the user in the cmdb_ci_business_app table and who is the survey respondent.

var result = new SNC.AssessmentCreation().createAssessments(typeSysID, sourceRecordID, userID);

var asmtGR = new GlideRecord("asmt_assessment_instance");

asmtGR.get(result.split(",")[0]);

asmtGR.setValue('trigger_table','cmdb_ci_business_app');

asmtGR.update();

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

1 REPLY 1

Prateek kumar
Mega Sage

How about below:

var typeSysID = 'c1d2fef9dbe3a5909cbf198d139619be';//The sys_id of the metric type or survey definition to generate assessments or surveys for.

var sourceRecordID = ''; 

var userID = current.it_application_owner//The sys_id of the user in the cmdb_ci_business_app table and who is the survey respondent.

var result = new SNC.AssessmentCreation().createAssessments(typeSysID, sourceRecordID, userID);

var asmtGR = new GlideRecord("asmt_assessment_instance");

asmtGR.get(result.split(",")[0]);

asmtGR.setValue('trigger_table','cmdb_ci_business_app');

asmtGR.update();

Please mark my response as correct and helpful if it helped solved your question.
-Thanks