Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


This file object method will move the cursor to the record with a matching key and read the record into the chosen buffer.

getRecord will have the same functionality as the CHAIN operation code in RPG. You may also use 'file.chain()' with the same parameters as this method.

Parameters
  1. Array of keys or key variable. Get the next record by key. If the file has no keys, it will default to the RRN.
  2. Boolean noLock. If true, no lock will be created. False by default.
  3. String recordName. Record format name.
  4. (Optional) Data structure. If a DS is passed in, the received buffer from the file will be placed into the specified DS.

Return Value

None.

Exception Handling

If there is a problem creating the data area, an Error API fetches the record specified by the search argument from the file.

Parameters

...

  • search argument
    The value can be a number, string, or array value specifying a relative record number (RRN), key value, or list of key values (array of number/string).

  • don't lock (optional)
    boolean true can be passed to avoid locking the record if the file is open for update/delete. If this parameter is set to boolean false or omitted records will be locked for update/delete files.

  • record format name (optional)
    A string value specifying the record format name can be passed.

  • input data structure (optional)
    A Profound.js data structure reference can be passed. 
    (info) If specified, the referenced data structure will be populated with the record data. If the data structure is not qualified, you must wrap the parameter with the pjs.ds() API.

Section


Column
width25%

Requirements



Column
width25%

RPG Equivalent


CHAIN


Column
width50%

Exception Handling


An Error instance will be thrown with the following properties:

  • message - The

...

  • message text.
  • error - The message id.
  • help - The message help text.

...


Example

Code Block
languagejavascript
titleRetrieve record with first key key equal to 101
pjs.defineTable("productspmyfile", { read: true, keyed: true, levelIds: [ '4AFA8C636F188' ] });
pjs.define("data", { type: 'char', length: 50, varying: read: true });
 
//Find a record by the key.
productsp.myfile.getRecord([101]);
 
//If the record has been
found..
if (productspmyfile.found())
{   data = pjs.char(prid);
}doSomething();

Video Tutorial

Widget Connector
width640
urlhttps://www.youtube.com/watch?v=1Dgl8yP2b2Q
height360