I am trying to compare two string values and if true exucute the automation for that report. The problem I am having is that it is always going false when I know the two strings match. I am taking the two global string variables and concatinating them together and then trying to compare that value to a static string variable using a string expression and then passing the results to an equals expression. I have also tried using a boolean expressing and setting the identifiers to a string. Any suggestions on what I am doing wrong?
I am also open to doing this in C# script but I am not sure how to execute an automation file from c#.
I have 40 different report types that I need to compare if the variable from the excel report matches the static report type I need it to then execute the automation script associated to that report type.
I have been tring to follow this thread and I can not seem to get the same out put.
@ZachT124 The StringUtils component has a method to compare two strings. The method is Equals. It can even ignore culture and case if those options are selected. That is what you want to use. I suspect you have a casing issue (where one string has capital letters and the other does not). Your boolean expression seems correct, although you've defined your input with the name of your variable. Normally, I would write my expression something like;
A=="Whatever string you want to hard-code"
It looks like you are passing the result of a boolean expression into an Equals which doesn't make sense. The boolean expression will return true or false and not a string. If you want to use the Equals method, pass it a string and then enter into the block the value you want to hard-code.
To write a method in C#, you would use the Script component. From there, you can write your C# as you like. Once you validate the script, the public methods you've written will be visible in the Object Explorer Methods section (where you normally grab methods for controls from Object Explorer).
@ThomasSasnett I have been trying to get the equals method to work. I keep getting the same error. I have verified that both of the inputs are displaying by adding a message before the equals and they both match. I am not sure what I am doing wrong here.
@ZachT124 To Upper is a method and must be called in your execution path. It looks like it isn't connected when being passed to your boolean expression. You need to have the execution path (yellow line) pass through it before you try to use the result. Here is an example of the various ways you can compare two strings. I suggest using the StringUtils.Equals method.