Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Access data source table in Groovy script

Speedy993
Speedy993 Posts: 65

I am trying to access a table defined as a data source in a Groovy script as part of a web scenario test. This script just needs to get a substring of one of the columns in the table.
The error I am getting says 'com.parasoft.data.DataSourceException: No Data Source column named BookingNbr'. My data source is defined as type Table and has these columns: BookingNbr DefendantName DefendantLastName DefendantFirstName DefendantMiddleName .
The script is very basic and is this:
import com.parasoft.api.*;
import java.util.*;

public String getBookingNbrSubstring(ScriptingContext context)
{
String bookingNbr = context.getValue("DataHold", "BookingNbr").get(1);
Application.showMessage("BookingNbr: " + bookingNbr);
String partialBookingId = bookingNbr.substring(4)
Application.showMessage("partialBookingId: " + partialBookingId);

return partialBookingId;
}

Any suggestions as to why I am getting this error? Can the script not find the table data source? This seems like such a basic thing to do.

Thanks!

Thanks

Comments

  • Speedy993
    Speedy993 Posts: 65

    My apologies. Somehow the 'Use data source' check box in the Edit Script window became unchecked and I did not notice that until just now. The script is working as it should now.

    Sorry and Thanks!