display.read()
Description
display.read() reads the user's response to the record format that was most recently written with display.screen.write(). It behaves exactly like calling display.screen.read() on that record format, but the module does not have to name the format. This is useful when the format that was written last is decided at run time.
If no record format has been written since the display was defined, the call throws error CPF5053 with status code 1255, because there is no record format to read.
This method is available in Profound.js version 6.3.0 and later.
Syntax
display.read()
display.read(dataStructure)Parameters
Data structure (Object, optional) - A Profound.js data structure reference, or a plain JavaScript object. If specified, the user's response is placed into the data structure or object instead of the program's global fields. If a data structure is not qualified, wrap the parameter with the pjs.ds() API.
Return Value
Object - The display file's field collection. The return value is not normally used; the response is read from the global fields or from the data structure passed as the parameter.
Examples
Example 1: Read the Last Written Format
Two formats are written and the response for the second one, screen2, is read without naming it.
Prerequisite: a Rich Display File named mydisplay.json with two record formats named screen1 and screen2.
pjs.defineDisplay("mydisplay.json");
mydisplay.screen1.write();
mydisplay.screen2.write(); // screen2 is now the last written format
mydisplay.read(); // Same as mydisplay.screen2.read()Example 2: Read a Format Chosen at Run Time
The format to show depends on the type of user. display.read() reads whichever format was written, so the decision does not have to be repeated for the read.
Prerequisite: a Rich Display File named customer.json with two record formats named detail and summary, and a global field named userType.
pjs.defineDisplay("display", "customer.json");
if (userType === "MANAGER") {
display.detail.write(); // Managers see the full detail format...
}
else {
display.summary.write(); // ...everyone else sees the summary format
}
display.read(); // Read the response for whichever format was writtenRPG Equivalent
READ