- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 04:26 AM
Hi Team,
I have two tables,
1.Incident
2.Personal incident,
Below are the screenshots of table list view.
Incident table: Here "Incident IDs" field having multiple incidents
Personal Incident table:Here having two fields(Incident number, Comments)
Requirement:
Fetch all the comments from Personal incident table to Incident table(Field-name:Personal comments) with respective Incident IDs field from incident table.
Ex:Incident Id's :INC0009005,INC0009009, So in Personal comments should have two comments :09876,hello
Note:Incident fields are string type in both tables.
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 05:23 AM
Hi,
You can write before Update/insert business rule on Incident table and use below script logic:
var comm =[];
var perInc = new GlideRecord('u_personal_incident');
perInc.addQuery('u_incident_number','IN',current.u_incident_ids.toSTring());
perInc.query();
while(perInc.next()){
comm.push(perInc.u_comments.toSTring());
}
current.u_personal_comments = comm.toString();
Please make required changes in above script as per your configuration.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 07:02 PM
without knowing and questioning why you are doing this you can try below code and let me know
var inc = GlideRecord("incident");
inc.addNotNullQuery("u_incident_ids");
inc.query();
var arr = [];
var j = 0;
while (inc.next()) {
var perinc = GlideRecord("u_personal_incidents");
perinc.addEncodedQuery("u_incident_numberIN" + inc.u_incident_ids);
perinc.query();
while (perinc.next()) {
arr[j] += perinc.u_comments.toString() + ",";
gs.log(arr[j]);
}
j++;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 05:23 AM
Hi,
You can write before Update/insert business rule on Incident table and use below script logic:
var comm =[];
var perInc = new GlideRecord('u_personal_incident');
perInc.addQuery('u_incident_number','IN',current.u_incident_ids.toSTring());
perInc.query();
while(perInc.next()){
comm.push(perInc.u_comments.toSTring());
}
current.u_personal_comments = comm.toString();
Please make required changes in above script as per your configuration.
Thanks,
Anil Lande
Thanks
Anil Lande