Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
(function execute(inputs, outputs) {
// ... code ...

//Get Source ids from existing Attestation;
//Check if an assessable record exists for all attestations in the group if not, throw an error message.
var sources = '';
var asmtmetricType = inputs.metricType; //Assessment metric type sys_id
var asmtAssignee =inputs.AttestationAssignee.sys_id.toString(); //Assessment assignee.
var assessmentList =inputs.AttestationList.trim(); //comma separated individual assessment.

var asmt = new GlideRecord("asmt_assessment_instance"); //Assessment instance table
asmt.addQuery("sys_id", "IN", assessmentList);
asmt.query();
while (asmt.next()) { //Need this while loop to check 1)check state and Assessable record.
if ((asmt.state == "complete" || asmt.state == "canceled")) {
outputs.out = "can't proceed, Attestation states are in Complete or Canceled, Please review.";
return;
}
//for each assessment check if assessable record exist
var assessableRecord = new GlideRecord("asmt_assessable_record"); //assessment assessable table
assessableRecord.addQuery("source_id", asmt.sn_grc_item);
assessableRecord.query();
if (assessableRecord.next()) {
sources = sources + "," + asmt.sn_grc_item;
} else {
outputs.out = "can't proceed, Assesssable record doesn't for this inntance please " + asmt.number + " review";
return;
}
}
sources = sources.slice(1); //Comma separated source sys_ids where assessment exist

//Create Grouped Attestation using below api
var result = new global.AssessmentUtils().createAssessments(asmtmetricType, sources + '', asmtAssignee, '');

//set grouped assessmemt as parent to all the instance
var asmtFinal = new GlideRecord("asmt_assessment_instance");
asmtFinal.addQuery("sys_id", "IN", assessmentList);
asmtFinal.query();
while(asmtFinal.next()){
asmtFinal.setValue("sn_grc_parent", result.split(',')[0]);
asmtFinal.update(); //set parent on to the each assessment
}

outputs.out = result.split(',')[0]; //return the grouped attestation instance id.

})(inputs, outputs);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Create a flow action with the inputs below:**
<img width="1483" height="712" alt="image" src="https://github.com/user-attachments/assets/08dbdce3-a189-4a29-af81-49f6c0fcccae" />


Add the script from action.js file

**Test and publish the action.**
<img width="1655" height="252" alt="image" src="https://github.com/user-attachments/assets/7a973573-016d-45a7-ba96-e8e4a495fbaf" />
**Plug this into the appropriate flow where you need to group the attestation.**
<img width="714" height="298" alt="image" src="https://github.com/user-attachments/assets/b82612fa-bbb7-4375-ba54-13fe2286b582" />

**Output:**

**List of Sample Assessments**
<img width="1655" height="252" alt="image" src="https://github.com/user-attachments/assets/297be503-ee0c-4495-baca-5693f9a3fa42" />

<img width="962" height="566" alt="image" src="https://github.com/user-attachments/assets/c79e4dc3-77ab-47b5-89e9-030972d01351" />

**Flow Context:**
<img width="1469" height="463" alt="image" src="https://github.com/user-attachments/assets/b9c894af-f39d-4f72-a606-473b2d757fdf" />

**Grouped Assessment:**
<img width="1252" height="694" alt="image" src="https://github.com/user-attachments/assets/b9ca0d68-dd9d-4381-97b7-2cfbec638f99" />
Loading