If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Set Session Parameters

Started by platipuss, 11 Aug 2009 09:59:13 AM

Previous topic - Next topic

platipuss

There is a knowledge base article that states how to retrieve the user session variables, but after updating the account the session parameter does not work.

     PropEnum[] properties = {PropEnum.searchPath, PropEnum.parameters};
     Sort[] sortBy = { new Sort()};
     QueryOptions options = new QueryOptions();
     BaseClass[] results = cmService.query(new SearchPathMultipleObject("CAMID(\"?????\")"), properties, sortBy, options);
     if(results.length > 0){
          for (int i = 0; i < results.length; i++){
               StringProp theSearchPath = results.getSearchPath();
          System.out.println("SearchPath \t = " + theSearchPath.getValue());
                  
          // Trying to change a value of a session param
          ParameterValueArrayProp parAVP = ((Account)(results)).getParameters();
          ParameterValue[] parV = parAVP.getValue();
          for(int x=0; x<parV.length;x++){
         if(parV[x].getName().equals("WIDGET")){
              System.out.println("Found WIDGET");
         ParmValueItem[] PVI = parV[x].getValue();
         SimpleParmValueItem SPVI = (SimpleParmValueItem)PVI[0];
         System.out.println("Orig: " + SPVI.getDisplay());
         SPVI.setDisplay("2");
         SPVI.setUse("2");
         System.out.println("After: " + SPVI.getDisplay());
         PVI[0] = SPVI;
         parV[x].setValue(PVI);
          }
            }
                  
            parAVP.setValue(parV);
            // apply to actual account
            ((Account)(results)).setParameters(parAVP);
      
            for (int j = 0;j < ((Account)(results)).getParameters().getValue().length ; j++)
            {
                System.out.print(((Account)(results)).getParameters().getValue()[j].getName() + "\t = ");
           // This value does return 2 as expected
           System.out.println(((SimpleParmValueItem)(((Account)(results)).getParameters().getValue()[j].getValue())[0]).getDisplay());
            }
                  
            // Trying to force an update of the parameters
            PropEnum[] updateProps = {PropEnum.parameters};
            UpdateOptions updateOpts = new UpdateOptions();
            updateOpts.setReturnProperties(updateProps);
                  
            // Run the update
            cmService.update(new BaseClass[] { results }, updateOpts);
              }
            
    }
         
   // Try to recieve the the same results again..
   results = cmService.query(new SearchPathMultipleObject("CAMID(\"?????\")"), properties, sortBy, options);
   if(results.length > 0){
      for (int i = 0; i < results.length; i++)
      {
         StringProp theSearchPath = results.getSearchPath();

         System.out.println("SearchPath \t = " + theSearchPath.getValue());
         for (int j = 0;j < ((Account)(results)).getParameters().getValue().length ; j++)
         {
            System.out.print(((Account)(results)).getParameters().getValue()[j].getName() + "\t = ");
            // This value returns to 1 when expected to still be 2
            System.out.println(((SimpleParmValueItem)(((Account)(results)).getParameters().getValue()[j].getValue())[0]).getDisplay());
         }
      }
   }

xiska

Hi

Not sure about it
is a System.out.println("Orig: " + SPVI.getUse()); possible?

It looks more like a report parameter not a user session parameter.
A user session parameter (lines per page, language, scin) has a name and a value and not a third background part.
These can be found at: PropEnum props[] = new PropEnum[] {PropEnum.searchPath, PropEnum.options};
A report parameter has a name a visible value and a background value.

please post the KB ID - might help.

greetings