- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2020 06:43 AM
Hi All,
I am trying to fetch the value of task number(task_id) i.e. change number from Assessment Instance (asmt_assessment_instance) table as soon as a record is inserted using a BR
Please refer below screenshot for BR and table
BR is created After Insert
But every time record is getting inserted in assessment instance table, no task_id is getting returned in BR
Please suggest, how should I fetch task_id of the inserted record
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2020 01:56 AM
From your BR name I am assuming that you want to count the number of assessments taken for a particular Change request.
Try the below BR-
On Assessment Instance table, every time an instance for "Change Risk Assessment" is set to Complete state-
Script will be-
var otherAssessmentCount = 0;
var checkIfOtherAssessment = new GlideAggregate(current.getTableName());
checkIfOtherAssessment.addEncodedQuery('metric_type='+current.metric_type.sys_id+'^task_id='+current.task_id.sys_id);
checkIfOtherAssessment.addAggregate('COUNT');
checkIfOtherAssessment.query();
if(checkIfOtherAssessment.next()){
otherAssessmentCount = checkIfOtherAssessment.getAggregate('COUNT');
}
var chg = new GlideRecord('change_request');
chg.get(current.task_id);
chg.u_total_assessments_taken = otherAssessmentCount; //Here add the name of your custom field on change_request
chg.update();
And the change request will be updated-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2020 06:57 AM
Hi Anurag,
I am writing this BR after insert only but still not returning any value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2020 07:08 AM
Hi,
Please use gs.addInfoMessage();
check in this info message adding task.id field.
Thanks,
Manjusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2020 07:13 AM
Ok, Im am not sure how or what are you doing or the use case, but can you change the condition of your BR to
after or before -> Update
&& task_id <changes>
&& task_id <Is not empty>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2020 07:20 AM
I am actually trying to fetch the assessment instance count for a particular change record.
for one of the requirements, I need to store a number of times risk assessment has been taken on a particular change record
I'll try to change the condition and let you know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2020 12:26 AM
Hi Anurag,
Every time we take risk assessment for a change_request record, One new record gets created in asmt_assessment_instance table for which source is the respective change record number.
That change record number we can see in task_id field.
I am not getting how a BR on "Update" will help here, am I missing something !