Records are not getting inserted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 05:39 PM
Hello,
I have two tables
1. Table1 - Field1(list type - referencing to cmdb_ci)
2. Table2 - Field2(Reference type - cmdb_ci)
Table2 is under Related Lists on Table1
Here, If i have 10 values in the Field1 from cmdb_ci, all those 10 values should get inserted as 10 new records in Table2 on Field2.
Here is the script i wrote - its getting the values under logs. but never getting the records inserted on Table2
ONBEFORE INSERT ON Table1:
function onBefore(current, previous) {
var list = current.Field1.toString();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
var cis = array[i].toString();
gs.addInfoMessage("hi1="+cis);
var x = GlideRecord('table2');
x.Initialize();
var abc = x.u_configuration_item = array[i].toString();
gs.addInfoMessage("hi2="+abc);
var xyz = x.Field2= current.sys_id;
gs.addInfoMessage("hi3="+xyz);
x.insert();
}
}
Can someone help me find the solution?, That would be very helpful.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 08:13 AM
Hi vtred,
Did you able to have a look at my last response?
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View