2 Replies Latest reply: Jun 14, 2016 11:07 AM by Manuel Capella RSS

    Passing the Field Selection into the Script

    vivek Moningi

      HI Guys,

       

      I have an Stored procedure in My SQL Server which I want to execute in Qlikview , I need to pass the value to the stored procedure by selecting on the field in Qlikview  upon which I need to reload the data to get the values returned by the proc

       

      I have used

       

      SQL EXEC Proc_Name '$(vSL)','$(vEL)';

       

      vStartLocation= getFieldSelection(Source Name)

      vEndLocationL = GetFieldSelection(Destination Name)

       

      LET vSL= $(vStartLocation);

      LET vEL = $(vEndLocation);

      the values vStartLocation and vEndLocation are declared in the variable overview and vEL and vSL are declared in the script, but the problem it is not passing the values into the variables

       

      Can someone help me on this?

       

      Thank you,

      Vivek

        • Re: Passing the Field Selection into the Script
          Stefan Wühl

          GetFieldSelection() can't be executed in the script context.

           

          Try creating a trigger OnSelect for fields Source and Destination Name in the front end (settings - document properties - triggers) and use an External - Set Variable action to copy the selection value to a variable.

          • Re: Passing the Field Selection into the Script
            Manuel Capella

            Hi vivek,

             

            You cannot use GetFieldSelections on Script, but you can use Vars on Script.

             

            On Script:

            IF Len('$(vSL)')>1 and Len('$(vEL)')>1 THEN

                 SQL EXEC Proc_Name '$(vSL)','$(vEL)';

            END IF;

             

            On design:

            Create one action on Field Triggers, on each field, on document properties.

            Source Name field -> Set Variable:

                 vSL -> =If(GetSelectedCount([Source Name])=1,[Source Name],' ')

            Destination Name field -> Set Variable:

                 vEL -> =If(GetSelectedCount([Destination Name])=1,[Destination Name],' ')

             

            Create a button with Show Condition:

                 IF(GetSelectedCount([Source Name])=1 and GetSelectedCount([Destination Name])=1,True(),False())

                 This button may have one action, External -> Reload

             

            Regards!!!!