Forum Discussion

richard_mischle's avatar
richard_mischle
Occasional Contributor
13 years ago

How to select Variable from drop down list if it displays differently

I saved a ten digit code to a variable from one screen it is saved as a datetimestamp using this code which displays as "0228093259"




function UniqueValue()

{  

  var unique;

  var StartPos = 0;

  var sLength = 4;

  var Result

  unique = aqConvert.DateTimeToFormatStr(aqDateTime.Now(), "%Y%m%d%H%M%S");

    //Log.Message(unique);

  

  Result = aqString["Remove"]( unique, StartPos, sLength );





   //Log.Message(Result);

   

  Project["Variables"]["UniqueValue"]=Result

}


I am now trying to select that variable from a drop down list on other screens, but it appears in the drop down list as "0228093259 / 19.999%" or "0228093259 / Description" and it is failing to select. 



I'm using the below looping structure to loop through the drop down list until it finds the variable:




var Index;

var Counter;

var FoundInd;

var Row;





Counter = Aliases["Allied_UniTrac"]["HwndSource_MainWindowPage"]["MainWindowPage"]["mainDockPanel"]["Grid"]["Workspace"]["Grid"]["Grid"]["appTabControl"]["Frame"]["CarrierProductPage"]["grdMain"]["ctlNewDataEntry"]["Grid"]["ScrollViewer"]["StackPanel"]["grdBasic"]["GroupBox1"]["StackPanel"]["StackPanel"]["cboIssueProcedures"]["wItemCount"];

Index = 0;





while (Index!=Counter)

  {

   Row = Aliases["Allied_UniTrac"]["HwndSource_MainWindowPage"]["MainWindowPage"]["mainDockPanel"]["Grid"]["Workspace"]["Grid"]["Grid"]["appTabControl"]["Frame"]["CarrierProductPage"]["grdMain"]["ctlNewDataEntry"]["Grid"]["ScrollViewer"]["StackPanel"]["grdBasic"]["GroupBox1"]["StackPanel"]["StackPanel"]["cboIssueProcedures"]["Items"]["Item"](Index);

      

   if (Row["Code"]!= (ProjectSuite["Variables"]["IssueProcID"]))

      Index++;

   else

      {FoundInd = Index

      Index = Counter;}  

  }  

  

  Aliases["Allied_UniTrac"]["HwndSource_MainWindowPage"]["MainWindowPage"]["mainDockPanel"]["Grid"]["Workspace"]["Grid"]["Grid"]["appTabControl"]["Frame"]["CarrierProductPage"]["grdMain"]["ctlNewDataEntry"]["Grid"]["ScrollViewer"]["StackPanel"]["grdBasic"]["GroupBox1"]["StackPanel"]["StackPanel"]["cboIssueProcedures"]["ClickItem"](FoundInd);    

}


Any idea how to make this work?

Thanks

2 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Richard,



    You can use the * and ? wildcards to mask dynamic parts of the value that you wish to click.

    For example, "0228093259*" will match both "0228093259 / 19.999%" and "0228093259 / Description", so you can simply use:



    ....["cboIssueProcedures"]["ClickItem"](Project["Variables"]["UniqueValue"] + "*");





    And, by the way, you can use the "%m%d%H%M%S" format string instead of "%Y%m%d%H%M%S" to generate the date-time stamp, so that you don't have to manually remove the year part.