Skip to content

model

Overview

This object holds information on the current "Record" available for use in the "Server Script". You can read the values ​​of "Column" using the properties. Assigning values to properties can change the display of column in the "Screen Index" or "Editor", but you cannot update "Record". To get "Record" from other tables or to update "records", use the "items Object".

Limitations

  1. Cannot be used with the conditions "When Loading Site Settings" or "When Processing View".
  2. Can only be used with the "Screen Index" condition "Before Row Display".
  3. Cannot get "Column" that do not have "Read Permission" in "Column Access Control".
  4. Cannot change the display of "Column" that do not have "update permissions" in "Column Access Control" even if you assign a value.
  5. Cannot get "Column" that does not exist on the screen. Use "AlwaysGetColumns Object" to get "Column" that is not on the screen.
  6. Cannot get the file with "Attachment Column". Can only get metadata (JSON) related to the attachment.

Properties

No Property Name Get Set Type Description
1 IssueId / ResultId Yes No long "ID Column"
2 SiteId Yes No long "Site ID Column"
3 Creator Yes No int "Creator Column"
4 CreatedTime Yes No DateTime "Created Datetime Column"
5 Updator Yes No int "Updater Column"
6 UpdatedTime Yes No DateTime "Update Datetime Column"
7 Ver Yes No int "Version Column"
8 Title Yes Yes string "Title Column"
9 Body Yes Yes string "Body Column"
10 StartTime Yes Yes DateTime "Start Column"
11 CompletionTime Yes Yes DateTime "Complete Column"
12 WorkValue Yes Yes decimal "Work Volume Column"
13 ProgressRate Yes Yes decimal "Progression Rate Column"
14 RemainingWorkValue Yes No decimal "Remaining Work Volume Column"
15 Status Yes Yes int "Status Column"
16 Manager Yes Yes int "Manager Column"
17 Owner Yes Yes int "Owner Column"
18 Locked Yes Yes bool "Lock Column"
19 Comments Yes No string "Comment Column"
20 ClassA to Z Yes Yes string "Class Column"
21 NumA to Z Yes Yes decimal "Numeric Value Column"
22 DateA to Z Yes Yes DateTime "Date Column"
23 DescriptionA to Z Yes Yes string "Description Column"
24 CheckA to Z Yes Yes bool "Check Column"
25 AttachmentsA to Z Yes No string "Attachment Column"
26 ExtendedRowCss Yes Yes string Row CSS
27 ExtendedRowData Yes Yes string Row data attribute
28 UpdateOnExit No Yes bool Update record after server script ends
29 ReadOnly Yes Yes bool Record is read-only

Methods

There are no methods.

Usage Example 1

The following example retrieves the "Update Datetime Column". As the time is obtained in UTC, convert it to JST as needed.

JavaScript
let updatedTime = model.UpdatedTime;

Usage Example 2

The following example retrieves the "Status Column". The value, not the name displayed, is retrieved.

JavaScript
let status = model.Status;

Usage Example 3

The following example sets the "Title Column" to 'New record title'.

JavaScript
model.Title = 'New Record Title';

Usage Example 4

The following example sets the "Status Column" to 300 (Review). The value, not the name displayed, is assigned.

JavaScript
model.Status = 300;

Usage Example 5

The following example sets the "Class Column" to "Tokyo".

JavaScript
model.ClassB = 'Tokyo';

Usage Example 6

The following example retrieves the value of a "Class Column" with "Multiple Selection" turned on. The retrieved value needs to be processed by replacing it into an array as follows. The option list has [[Groups]] set.

JavaScript
let groupIdList = JSON.parse(model.ClassA);
for (let groupId of groupIdList) {
    context.Log(groupId);
}

Usage Example 7

The following example assigns "Design" and "Construction" to a "Class Column" with "Multiple Selection" turned on. Assign JSON-formatted strings for "Class Column" with "Multiple Selection" turned on.

JavaScript
let data = [];
data.push('Design');
data.push('Construction');
model.ClassA = JSON.stringify(data);

Usage Example 8

The following example sets yellow background CSS for records where the "Manager Column" or "Owner Column" is the logged-in user in the "Screen Index". The condition "Before Row Display" is used. Combine "Server Script" and "Style".

JavaScript
if (model.Manager === context.UserId || model.Owner === context.UserId) {
    model.ExtendedRowCss = 'own';
}
CSS
/* before ver1.4.19.2, the syntax ".own {~}" use to specify elements. */
.grid .own td {
    background-color: yellow;
}

Usage Example 9

The following example adds the data attribute "data-extension" to records in the "Screen Index". *The attribute name is fixed as "extension". To add multiple data attributes, store them in a JSON object and set them.

JavaScript

model.ExtendedRowData = JSON.stringify({ timeout: limit });

Generated HTML:

HTML

<tr class="grid-row" data-extension="'{"timeout":300}'"> ...

Reference it in a script using jQuery's data().

JavaScript
const handler = function () {
    $('table tr').each(function (i, e) {
        var ext = $(e).data('extension');   // var ext is a JSON object
        if (Date.now() > ext.timeout) {
            ...
        }
    });
};

Usage Example 10

The following example sets today's date in the "Date Column" and updates the record after the server script ends.

JavaScript
model.DateA = utilities.Today();
model.UpdateOnExit = true;

Example Output

Output example of model.AttachmentsA (formatted from the output string):

[
    {
        "Guid": "18F34BCD594F4FF6A94D7C0F9C8AB5D4",
        "Name": "test.txt",
        "Size": 4,
        "HashCode": "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg="
    }
]

Output example of model.Comments (formatted from the output string):
[
    {
        "CommentId": 1,
        "CreatedTime": "2022-12-22T14:42:56.7963585+09:00",
        "Creator": 1,
        "Body": "The text of your comment goes here"
    }
]

Detailed Information

  1. On the "Screen Index", this can only be used if the condition is set to "Before Row Display". The "Server Script" is executed for each row, and the records of each row are stored in the "model object".
  2. In the "Editor", the information of the "record" currently displayed on the screen is stored in the "model object".

Supported Versions

Supported versions Contents
1.3.27.0 and later Added Comments
Added Attachments