8 Replies Latest reply on Feb 14, 2020 10:25 AM by Brice-Emmanuel Loiseaux

    CMDBSYnc : Evaluate the result of a Traverse

    Amar Achmedan
      Share This:



      In the CMDB Sync script for ComputerSystem, I'm trying to retrieve the location information and send it to the CMDB as an attribute.


      The code works fine as long there is a location information in the item. But there the location is missing I get an error during the sync to the CMDB :


      CMDB.Printer_Printer.Printer_Printer:46: 'loc' is not a valid subgraph at this point


      This is the code :


          mapping on Host as host

              computersystem -> BMC_ComputerSystem;

                 traverse ElementInLocation:Location:Location:Location as loc

                  end traverse;

          end mapping;



      loca := "";

      for each loc do

           loca := loc.name;

      end for;

      log.info("location %loc.name%");


      I suppose my loc is null becaus ethere is no location to traverse trough.
      How can I check if "loc" is valid before I start to loop on it?

      Can I just include the loop in a "if" test? 

      if loc then


      end if;



      Thank you