Mass update of SRC Items

Dear folks,

I have a long list of SRC items (over 400) that use the "Open a Change" connector and I would like to update the assignment group the change ticket is assigned to.  How can I do this with a mass update (or via the Oracle database)?  The filename for the SRC item is a joindef file (joinsvcDisplay) and the field I want to update is presented as a variable ($assign.dept).

What's the best way to do a mass update of the contents of that variable?

Thanks,

Ulises

 

 

  • There's probably an existing JS somewhere in SM which can be called to replace an XML value, but after a quick glance I didn't see one. But I'm on coffee overload this morning, so I felt like writing something. ;) This may not be the prettiest way to do this, but it works. Just save this in a ScriptLibrary somewhere, edit the two lines indicated, and Execute it.

    var itemQ = "interface.type=\"Open a Change\"";
    //If needed, further restrict the records updated
    //by using this query to filter on other fields.
    
    var replaceGroup = "NEW GROUP";
    //Enter the new Assignment Group name.
    
    
    var item = new SCFile("svcCatalog");
    var iRc = item.doSelect(itemQ);
    
    while (iRc == RC_SUCCESS) {
    
        var t = item.interface_info.indexOf("<assign.dept>");
        var i1 = t   13;
        var i2 = item.interface_info.indexOf("</assign.dept>")
        var currentGroup = item.interface_info.substring(i1, i2);
        item.interface_info = item.interface_info.replace(currentGroup, replaceGroup);
        item.doUpdate();
        iRc = item.getNext();
       }

    The Assignment Group which the Open a Change connector uses is stored in XML form (essentially) in the interface.info field of an svcCatalog record. The joinsvcDisplay file merges svcCatalog and svcDisplay records for viewing. So this script goes behind that to the actual svcCatalog to perform the updates.

  • Verified Answer

    AChandler,

    God bless coffee! Just read it and I think this will work; your code assumes that all current items are assigned to one group, doesn't it?  So if I want to do something as "find me all the items assigned to X group and replace the group with Y" I'll need to update the initial query as indicated here:

    var itemQ = "interface.type=\"Open a Change\"";

    //If needed, further restrict the records updated

    //by using this query to filter on other fields.

    I will do that and I'll update the post with the results. 

    Best regards,

    Ulises

     


  • Ulises Jorge Bido wrote: if I want to do something as "find me all the items assigned to X group and replace the group with Y" I'll need to update the initial query

     


    Yes sir, something like this should do it:

    var itemQ = "interface.type=\"Open a Change\" and index(\"OLD GROUP\",interface.info)>0";
  • AChandler,

    Just tested it and it worked!  Thanks a lot, this is an amazing solution.

    Kind regards,

    Ulises