Compare pk to string (UUID)

The following doesn’t work,

var ds = databaseManager.convertToDataSet(forms[focusFormName].foundset); // returns primary key dataset
for (var i = 1 ; i <= ds.getMaxRowIndex() ; i++) {
ds_row_id = ds.getValue(i,1).toString();
if(ds_row_id == row_id) {
forms[focusFormName].foundset.setSelectedIndex(i);
break;
}
}

If I trace, I can see that ds_row_id is not enclosed in italics, but row_id is contained in the italics. For example:

ds_row_id: 380B9C6C-4B01-49D4-8C77-BB33B1590EA7

row_id: “380B9C6C-4B01-49D4-8C77-BB33B1590EA7”

So it doesn’t seem to understand that I want to compare the pk to a string. It appears to ignore the “.toString()” portion.

Is there a way to do this?

Hi Don,

working late… :wink:

Anyway, I tried your code and the equal test works for me.
How did you setup your db-column?
I assumed it has type ‘MEDIA’ with Servoy’s UUID generator and the UUID flag set.

Then when I output the different UUID’s + their types, I get:

JavaObject: F1AE923D-E6D7-4F7E-BD18-9CD7227AB1A8 (pk column)
JavaObject: 6670F084-05CD-494D-8F27-254EDA3A3CC1 (dataset value)
string: 6670F084-05CD-494D-8F27-254EDA3A3CC1 (dataset value 'toString')

In my case it even compares the string to the javaobject and passes that test, which is even more surprising…

Maybe you can post your setup and ideas on what your trying to accomplish?

Hello Marc!

For my pk fields I am using type string 50.

It’s a clickable list that we’ve discussed before. It lists the items that the user needs to fix, in order to save the record without an incomplete box being checked on the record.

When the user clicks on a listed item, it takes the user to the form tab containing the field, and highlights the field/data provider. This almost works (Servoy sometimes highlights the wrong field when the form switches to the new tab).

In the case of related many fields which appear in their own tab panels, the goal is to highlight the appropriate row. In this case, instead of passing a field name, I am passing the name of the included list form, along with the UUID (eg., “form_name&UUID”. I get the dataset, and when I find the row that matches the UUID, it highlights.

Here’s an example of the dataset when there are three “included” (listed) records,

=>ds
BufferedDataSet {Columnnames[stc_student_contact_id]} 
row_1[32635FE4-C7B5-4865-AB08-E8E21BFE523F] 
row_2[984A603E-4A9A-431B-BA98-9BFF13380D11] 
row_3[380B9C6C-4B01-49D4-8C77-BB33B1590EA7]  {rowColumns:array[1],rowIndex:-1,row_1:array[1],row_2:array[1],row_3:array[1]}

…and the wierdest thing has happened…

It started working :shock:

I don’t understand it, but somehow when I am coding things that should work don’t, and then when I start Servoy again they begin working.

Thanks so much for looking at the code. It’s really helpful having a second set of eyes.

Don