Getting "Error loading primary key data, For input string:"

I am getting a “Error loading primary key data, For input string:” error when the program tries to pull in data into a fk field. This error was not present before and the information went in as it was supposed to. I have apparently done something, but I am not sure what. Below I have put all information that I thought would be relevant, but if I need to I will post more info.

Server Information
Servoy version 3.5.7-build 520, repository version 31
Current time: Tue Sep 30 10:12:39 EDT 2008
Uptime: 1 day 10 hours 9 minutes 28 seconds

User Information
Logged in as: Philip

JDK Information
java.vm.name=Java HotSpot™ Client VM
java.vm.version=1.5.0_13-121
java.vm.info=mixed mode, sharing
java.vm.vendor=“Apple Computer, Inc.”

Operating System Information
os.name=Mac OS X
os.version=10.4.11
os.arch=ppc

System Information
runtime.allocatedMemory=65088K
runtime.usedMemory=23017K

The database is a Sybase 9 Database.

The method that is calling the import:
// This method searches the CONTACTS table for matches to apply to buying realtor in the INSPECTION record
// If an exact match was found, a relation is established to that contact record
// more than one matches shows a chooser
//
// If no matches were found, then any existing link to a contact will be deleted

// remove existing relation to contact
fk_buyer_realtor_id = null;
controller.relookup();

// recommit changed changed data (this time calc will stick b/c no related contact to override)
var new_value = arguments[1];
var dp = elements[application.getMethodTriggerElementName()].getDataProviderID();
controller.setDataProviderValue(dp, new_value);

// if contact name was deleted or there isn’t sufficient name info, delete any link to contact
if(!buyer_lst_name || !buyer_fst_name)
return;

// get matching contact ids
var contacts = forms.frm_insp_find_contact_dlg.find_contact(buyer_lst_name, buyer_fst_name);
if(!contacts)
return;

// Check Web-Client
var is_web_client = application.getApplicationType() == 5;

// ask user to auto-populate (Not Web Client)
if(!is_web_client){
var msg = “Matching contact information for a buying realtor was found in the CRM.\n”
msg += “Would you like to auto-populate the rest of the fields with this information?”;
var confirm = plugins.dialogs.showQuestionDialog(“Auto-Populate Buying Realtor”, msg, “Yes”, “No”);
}

// confirmed by user or web client
if(is_web_client || confirm == “Yes”){

// multiple matches
if(contacts.length > 1){
var contact = forms.frm_insp_find_contact_dlg.show_chooser();

// action canceled by user
if(!contact)
return;

// single hit
} else {
var contact = contacts[0];
}

// create relation
fk_buyer_realtor_id = contact;
databaseManager.saveData();
}

The fk data provider is as follows with the headers in the first row:

Name |Type | Length|Row Ident|Allow Null|Sequence|Properties|
fk_buyer_realtor_id | Text | 40 | Blank | Yes | None | None |

The data provider that is being pulled in is:

Name |Type | Length|Row Ident|Allow Null|Sequence|Properties|
id |Text | 40 | pk | No | None | None |

I have looked in Sybase Central and made sure that the properties were consistent and they were. What could have changed that would all of the sudden cause the import not to work anymore? Any help would be greatly appreciated.

Does this error happen every time when running this method? Have you stepped through the method using the debugger? What line causes the error?

Joas:
Does this error happen every time when running this method? Have you stepped through the method using the debugger? What line causes the error?

I did that after reading your response. Here is the error message that I got when stepping through the method.

The undefined value has no properties calling getDataProviderID.
Callstack:
frm_insp_orderform.search_buyer
ConversionError: The undefined value has no properties calling getDataProviderID. (search_buyer; line 14)
frm_insp_orderform.search_buyer

So it is this line that causes the error:

var dp = elements[application.getMethodTriggerElementName()].getDataProviderID();

Put a breakpoint in front of this line and when the debugger reaches that point, find out what the value for “application.getMethodTriggerElementName()” is by using the Evaluate tab.

How is this method triggered? By an onDataChange event? Are you sure that the element that triggers the method is on the same form as the method?

The problem appears to be more basic than I thought it was. I tried to import an earlier version of the solution and got this message at the end of the import. “The server version of the column ‘contact_id’ of table ‘contacts’ in server allows NULL values while the import version does not.” The method that I am getting the original error on was supposed to add the information from one form into another form if there was matching info. So I went to the contact manager and tried to add a new contact by clicking on the new contact button which has the following method:

controller.newRecord();
elements.tabs.tabIndex = 2;
forms.mod_ai_crm_contact_detail_general.controller.focusFirstField();

and got the following message: “Cannot save form data” I got the details and the details were the following: “com.servoy.j2db.ApplicationException: Cannot save form data com.servoy.j2db.dataprocessing.DataException: ASA Error -95: Column ‘id’ in table ‘contacts’ cannot be NULL”.

I stepped through the method and was taken to this method:

if(globals.shouldAuditLog) //detaults to 1
{
var rec = arguments[0];

var tenant = globals.g_user_tenant_id;
var user = globals.g_user_emplyoee_id;

var tblname = databaseManager.getTable(rec);
var pkarray = tblname.getRowIdentifierColumnNames();
var pkname = null;
var pkvalue = null;

for ( var i = 0 ; i < pkarray.length ; i++ )
{
if (pkname != null)
{
pkname = pkname + “;”
pkvalue = pkvalue + “;”
}
pkname = pkname + pkarray*;*
_ pkvalue = pkvalue + rec[pkarray*];_
_
}*_

* forms.audit_log.controller.newRecord(true);
forms.audit_log.server_name = tblname.getServerName();
forms.audit_log.table_pkname = pkname;
forms.audit_log.table_name = tblname.getSQLName();
forms.audit_log.table_pkvalue = pkvalue;
forms.audit_log.tenant_id = tenant;
forms.audit_log.user_id = user;
forms.audit_log.action_type = “insert”
_
}*_
The error message comes up when I try to step into the last line in the method.

Does anybody have any suggestions on this? This is a major issue for my users and I am hopeful somebody here can help with this. Thanks

You get this error, because you’re trying to save a contact record without the primary key field (id) filled in.
To solve this, you have to go to your id-column in your table properties and go to “Auto Enter”, there you can select “Servoy sequence”. Make sure that you do “Sync with db” (in Servoy 3.x) or “Calculate from data” (in Servoy 4.x) to make sure that the sequence is up to date, and do “Save” or “Update” afterwards.

If you have done this, your id-field is automatically filled with an increasing integer, and that should keep your db from whining :)