Forum Discussion

Luukdb's avatar
Luukdb
Contributor
2 years ago

Comparing table data in IF not working

Hello,

 

I have this weird problem were everything seems correct but TC isn't doing the correct steps.

 

I have a data driven loop, and I am going to check if the product number is a specific product, and it should do the steps I want.

 

This has worked in the past, not sure why it stopped working.

 

In the image below, in the blue box, the product number is filled in - this is correct.

 

For the sake of testing, I added the yellow box - these also give and store the correct values.

 

The problem is in the red box, for some unknown reason it just skips the if.

 

Below is a small snippet of the test log, and you can see that the log action provided the correct product number.

 

Also, you can see that the text in the textbox is also the correct value.

 

And lastly a screenshot of the if itself.

 

Can anybody help me notice the issue?

 

Thanks in advance.

 

Luuk

  • Are you able to open your project file (.mds file) in Notepad++ or something similar to view your project variables. For example,

    which represents this in TC,

    Can you see any spaces inbetween the quotes of Cells?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    While looking at BackToBasic.js script, for //Purchase Hellwege where Project.Variables.SupplierID == "BUN001", the if statement contains these lines of code,

    if(Project.Variables.PurchaseOrderProducts.Iterator.Value("ProductNumber") == "L-24-119-00\r\n")
    
    // And
    
    if(Project.Variables.PurchaseOrderProducts.Iterator.Value("ProductNumber") == "L-12-455-00\r\n")

    Note the "\r\n" at the end of the string which indicates carriage return and line feed characters!

     

    If you were to update your keyword test to include "\r\n" for,

    if(Project.Variables.PurchaseOrderProducts.Iterator.Value("ProductNumber") == "L-00-030-00\r\n")

    Will that work?

     

     

    Again, I can't see anything wrong with the code you have provided. It always leads me back to your data.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Are you able to open your project file (.mds file) in Notepad++ or something similar to view your project variables. For example,

    which represents this in TC,

    Can you see any spaces inbetween the quotes of Cells?

  • What do you mean by including the "\r\n"? Where should I put it? When I put this in the IF it fails again.

     

    This is the data of the PurchaseOrderProducts I want to check.

    I do see that some have 
&#10 and others do not.

    What does that even mean?

  • Hahaha, you were right!

     

    Do I remove those things via Notepad++ and save the project file or in TC itself?