CA Service Management

  • 1.  how to use the values selected in multi select Option

    Posted Jul 01, 2016 07:05 AM

    Hi Team,

     

    we are using service catalogue 12.7. we got some new requirement regarding multiselect option.

     

    ALREADY IMPLEMENTED:

    we have two dropdown list. if the user selects the value in the first dropdown field, result values are used in the second dropdown field through the report data(by quering).

     

    $({'regionss':ca_fdGetSelectedOptionValues(ca_fd.formId,'region')[0]})

     

    select sub_region as subreg_name, sub_region as sub_name from inventory_region where region='%regionss%'

     

     

     

    NEW REQUIREMENT:

     

    How to list the result values in second dropdown, if users selects multiple option in first dropdown.



  • 2.  Re: how to use the values selected in multi select Option

    Posted Jul 29, 2016 10:47 AM

    Hey Hemalatha,

     

    Using an IN clause is available in Catalog 14.1, but not in 12.7. But with some tricks you can manage it.

     

    Let me explain you how i did it :

     

    First of all, you will need a new function on your SQL Server to parse comma separated string and return a table

     

    Something like (I found this function on stackOverflow) :

     

    create function splitString
    (
         @input NVARCHAR(MAX),
         @Character CHAR(1)
    )
    returns @Output TABLE (Item NVARCHAR(1000))
    
    AS
    BEGIN
         DECLARE @StartIndex INT, @EndIndex INT
    
         SET @StartIndex = 1
         IF SUBSTRING(@Input, LEN(@Input)-1, LEN(@Input)) <>@Character
         BEGIN
              SET @Input=@Input+@Character
         END
         WHILE CHARINDEX(@Character,@Input) >0
         BEGIN
              SET @EndIndex = CharIndex(@Character, @Input)
              INSERT INTO @Output(Item)
              SELECT SUBSTRING(@Input,@StartIndex,@EndIndex -1)
              SET @Input = SUBSTRING(@Input, @EndIndex+1, LEN(@Input))
         END
         RETURN
    END
    GO
    
    

     

    You need two report object :

    First one (For region in your case i assume)

    select id as value, name as label from tableRegion
    

     

    Second one (For sub-region in your case)

    select id as value, name as label from tableSubRegion where idRegion in (select * from splitString(%STRING%,','))
    

     

    On your sub-regions list you can add this one in the attribute to specify the variables for the report object

    $({'STRING':ca_fdGetSelectedOptionValues(ca_fd.formId,'lst_region').join()})
    

     

    And for the attribute on change of your regions select, you can add :

    ca_fd.js.selectRegion()
    

     

    And define the selectRegion function in your script :

     

    selectRegion : function()
    {
         ca_fdFetchSelectData(ca_fd.formId,'lst_subRegion');
    },
    

     

     

     

    Hope this helps

     

    Pier