Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.
Endpoint Management Community Blog

How can the folder path of a console object be retrieved in NS 7?

Created: 01 Oct 2009
btowne's picture
0 0 Votes
Login to vote

In NS6 there was a function called "GetItemPath" in which return the path for an object in the Console. How can I get the folder path in NS 7?

"GetItemPath" function does not exist in the NS 7 database. Here is the sql behind creating that function for changes in the NS 7 database:

USE [Symantec_CMDB]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER FUNCTION [dbo].[GetItemPath]

(

      @Guid Varchar(40)

)

Returns varchar(8000)

 

AS

 

Begin

 

DECLARE    

  @SearchGuid VARCHAR(40),    

  @ItemPath VARCHAR(500),    

  @ExitCounter INT    

    

SET @SearchGuid = @Guid

SET @ItemPath = ''    

SET @ExitCounter = 0    

    

WHILE @ExitCounter = 0    

BEGIN    

  IF EXISTS (SELECT * FROM ItemFolder WHERE ItemGuid = @SearchGuid AND ParentFolderGuid != 'D0E33520-C160-11D2-8612-00104B74A9DF')    

  BEGIN    

    SET @ItemPath = (SELECT TOP 1 [Name] + '/' FROM Item WHERE [Name] NOT LIKE '/_%' escape '/' and Guid =     

                      (SELECT TOP 1 ParentFolderGuid FROM ItemFolder WHERE ItemGuid = @SearchGuid)    

                    ) + @ItemPath    

    SET @SearchGuid = (SELECT TOP 1 ParentFolderGuid FROM ItemFolder WHERE ItemGuid = @SearchGuid)    

  END    

  ELSE    

  BEGIN    

    SET @ExitCounter = 1    

  END    

END    

 

RETURN @ItemPath

 

END

Usage of this function:

SELECT [Symantec_CMDB].[dbo].[GetItemPath] ('GUID')

Where GUID is the guid of your object.