AssessmentCreation - Global
The AssessmentCreation API provides methods that administrators can use to generate assessments and surveys.
There are multiple ways to call the createAssessments() method. You must set the typeID parameter in all cases to identify a metric type or survey definition.
- Whether the target is an assessment or survey
- Whether the assessment schedule type is on-demand or scheduled
- Survey schedule periods
- Parameters provided
For example, when the method is called with only the typeID parameter set, the method searches for stakeholders or survey users to send invitations to. In contrast, when the method is called with the typeID and userID parameters set, it attempts to send invitations to the specified users.
AssessmentCreation - createAssessments (String typeID, String sourceRecordID, String userID)
Creates one or more assessments or surveys for the specified metric type or survey definition.
| Name | Type | Description |
|---|---|---|
| typeID | String | The sys_id of the metric type or survey definition for which to generate assessments or surveys. |
| sourceRecordID | String | One or more comma-separated survey definition sys_ids to include in the assessments generated. There must be an assessable record associated with the specified metric type for each source record. If this parameter is left blank, the assessments generated includes all assessable records for the specified type. This parameter is for use with assessments only. |
| userID | String | One or more comma-separated sys_ids of users to which to send assessment or survey instances. If this parameter is left blank, the assessment stakeholders or survey users receive instances. This parameter is required for on-demand assessments. |
| Type | Description |
|---|---|
| String | If the method is successful, it returns a comma-separated string such as
7a2ad2253784200044e0bfc8bcbe5de1, 10, b7e8b5d4c0a80169008b49e468920048 (Instance ID,
number of instances, Group ID) with the following values:
If the method is unable to generate assessments or surveys, it returns one of the error codes. Error Codes
|
This code example shows how to generate an assessment instance in a service portal widget. This example will not work if Schedule Type is set to On Demand.
(function() {
var gdtSurvey = new GlideDateTime();
if (gdtSurvey.getDayOfMonthUTC() == 23) {
(new SNC.AssessmentCreation()).createAssessments('d902e09a075730101263f19d7c1ed03a', // Assessment metric type sys_id
'4baec2fe07d3f0101263f19d7c1ed0a6', // Assessable record which is the source of the assessment
gs.getUserID()); // Users ID to send the assessment instances to
}
})();
Return results:
bbf0b9b8072330101263f19d7c1ed00b,1,33f0f978072330101263f19d7c1ed05f