Generate Survey From Script
If you want to generate a survey and assign a user from any server-side script like business rule, Script Include you can use the code below.
Note: This code only works on Global Scope. Suppose you are in a custom scope call from there to global scope script include.
try {
var sourceRecordID = '';
var result = new SNC.AssessmentCreation().createAssessments(typeSysID, sourceRecordID, userID);
var instanceId = result.split(",")[0];
var asmtGR = new GlideRecord("asmt_assessment_instance");
if (asmtGR.get(instanceId)) {
asmtGR.setValue('trigger_table', table);
asmtGR.setValue('trigger_id', tid);
asmtGR.update();
}
return instanceId;
} catch (ex) {
gs.info('Line 22 ' + ex);
}