03-24-2014 03:12 AM - edited 03-24-2014 03:14 AM
We have a requirement such that in device table (CIs), when we update the CI Owner (contact.name in device table) with the operator name (contact.name in operator table), there is an array field in the Operator table (owner.ci) which should update the CI Identifier (logical.name in device table). The functionality should be similar to operator and Assignment Group. Similar as when the Operator is updated with Assignment Group, the Assignment table is updated with Operator name and vice versa.
As of now, I have wriiten a code mentioned below. With this code I am able to Update the Operator record with the CI name, but if I change the Owner of the CI, the CI name still remains in the old Operator Record and in addition to that also appears under the new CI Owner.
var operator = new SCFile("operator")
var ciOwner = operator.owner_ci;
var operatorRecord = operator.doSelect("contact.name=\""+record.contact
if(operatorRecord == RC_SUCCESS)
Thanks in advance.
Points will be awarded.
Solved! Go to Solution.
03-24-2014 03:42 AM
I guess you are doing that in triggers.
Add this script fragmnt there. I have not tested it though
var foperator = new SCFile("operator")
var foperatorRecord = foperator.doSelect("contact.name=\""+oldrecord.con
if(foperatorRecord == RC_SUCCESS)
var fresults = new Array();
for (var i=0;i<length;++i)
if (foperatorRecord.owner_ci[i] != null)
var dup = false;
if(fresults[k] == foperatorRecord.owner_ci[i])
dup = true;
fresults[fIndex] = foperatorRecord.owner_ci[i];
03-24-2014 08:15 PM
Thank you very much.
03-25-2014 12:56 AM
Why are you copying this information to the operator record?
If you just want to be able to see which CIs are assigned to a user, they can easily be displayed using a Virtual Join that shows all equipment assigned to the user (this can be added to the contacts form, operator form, or both easily). When opening a ticket the out of box filters already include any equipment assigned to the contact in the fill results for Affected CI.
03-25-2014 03:58 AM
Hello, It might have gone in a loop as i have written it without a system.
If you were writting the first one yourself , debug it using prints and try t catch it.
03-25-2014 09:00 PM
We have a requirement such that whenever a CI is mapped to a Contact, the list of CIs mapped to that user should be displayed in an array field in the Operator record. And when the contact is disassociated from the CI or the CI is mapped to another user, it should be updated in the Operator record array field accordingly.
03-25-2014 09:15 PM
You can accomplish that without copying the data to the operator record (you can use a virtual join). If the only requirement is to display the user's associated devices on their operator record, there is no need to copy them.