Forum Discussion
tristaanogre
7 years agoEsteemed Contributor
OK... first things first... go to https://www.w3schools.com/js/default.asp and take the basic tutorials on writing JavaScript code... this request this time is probably day one high-school programming course. If you're going to be doing automated test development, I would STRONGLY recommend taking online tutorials or classes to get familiar with basic programming techniques.
That said... here's how I would write it
var captionString = OrderEntry2.WndCaption; //This returns the value of the property var hyphenPosition = aqString.Find(captionString, "-"); //This finds the position of the hyphen var tableIDLength = hyphenPosition - 7; //We know the starting position is 7 so simply subtract that from the hyphen start var tableID = aqString.Trim(aqString.SubString(captionString, 7, tableIDLength)) //Use Trim and Substring to get the actual TableID Log.Message(tableID)
Code is tested and functional based upon a WndCaption in the format of Order #123456 - IPO
msap
7 years agoFrequent Contributor
Thanks Martin. I was trying to see whther we have different functions for using subtract, and operators are out of my mind.Sure will go through the course again thanks!