Retrieve primary key values

Caution: You can enable primary key mode only after you have upgraded to Service Manager 9.32 applications or later. Otherwise, the following procedures may have unexpected results.

You can use the following example to derive your own scripts to read the primary key values:

  1. Start Service Manager and then log in as an administrator.

  2. Navigate to dbdict.

  3. Create a testkey table with a primary key defined.

  4. Create a detailed form based on the testkey table.

  5. Insert several data points into the testkey table.

  6. Navigate to ScriptLibrary.

  7. Create a new script by copying the code below:

    var retValue;
    var retCode;
    var keyValues = new SCDatum();
    var file = new SCFile("testkey");
    file.doSelect( "true" );
    retValue = system.functions.rtecall("getprimary", retCode, keyValues, file );
    print( "file testkey is ", file );
    print( "The return value of getprimary is ", retValue );
    print( "The value of primary key is ", keyValues );
  8. Execute the script.  You should see output that resembles the following:

    The value of primary key is  [C++ object SCDatum] - {'12/12/12 00:00:00', "54343"}
    The return value of getprimary is  true
    File testkey is  [C++ object SCFile] - testkey={['12/12/12 00:00:00', "fgdf", , "54343"]}