Oracle CRM On Demand JavaScript API Developer's Guide > JavaScript API Reference >

Methods for the Field Object


Table 5 describes the methods that are available for the Field object. These methods are used in the getting and setting of field values and in the color coding of field colors.

For information about finding the field names that you must use when working with these methods, see Finding Field Names.

Table 5. Methods for the Field Object
Method Name
Return Type
Description
Sample Code
Notes

getField(fieldName)

A field object exposing the getValue and setValue methods or null, if the field is not found on the screen

Gets the field on the current screen that is identified by the fieldName parameter.

oraclecrmod.getField('Parent Account Name');

For information about the ListRow getField() method, see Table 8.

getValue()

The field value string

Gets a value for a field in the current screen.

oraclecrmod.getField('Location').getValue();

For a check box field, the return values are Y for selected, and N for deselected.

getLICValue()

The field's language independent code (LIC) value as a string

Gets the LIC value for a field in the current screen.

oraclecrmod.getField("Type").getLICValue();

For more information, see Getting and Setting LIC Values of Picklists.

setValue (fieldValue)

The new field value string that was just set, or null if the method fails

Sets a value for a field in the current screen. This can be a New page, an Edit page, a Detail page, or a List page.

For a New, Edit, or Detail page:

oraclecrmod.getField('Type').setValue("Customer");

For a list, including a related item list:

oraclecrmod.getList("AccountList").getRow(0).getField("Type").setValue("Customer");

For information about the limitations of setValue(), such as field types not supported, see Limitations When Using the setValue() Method.

NOTE:  On Detail pages, and for lists, setValue() does not commit values to the database and update the screen. The commitValues() method must be called to commit the values. See Table 6 and Table 7.

setLICValue(fieldValue)

The new language independent code (LIC) field value string that was just set, or null if the method fails

Sets a LIC value for a field in the current screen.

oraclecrmod.getField('Type').setLICValue("Customer");

For a Detail page:

oraclecrmod.getField("Priority").setLICValue("Low"); oraclecrmod.getField("Region").setLICValue("West"); oraclecrmod.getForm().commitValues(commitValuesHandler);

The LIC value is used to set the field's value. The language dependent code (LDC) value will still be displayed on the screen.

For more information, see Getting and Setting LIC Values of Picklists.

setColor(JSONObject)

this

Sets the colors for a Field by passing in a JSONObject.

field.setColor({"labelBgColor":"Red","labelTextColor":"Yellow","valueBgColor":"Yellow","valueTextColor":"Red"});

Elements supported in the JSONObject:

  • labelBgColor. The field label background color.
  • labelTextColor. The field label text color.
  • valueBgColor. The field value background color.
  • valueTextColor. The field value text color (not applicable on Edit pages).

Any other elements are ignored.

For information about the color values the elements can have, see Color Values for JSONObjects.

getColor()

JSONObject

Returns the JSONObject that was set for color coding the field.

color = field.getColor();

If no JSONObject was set using setColor(), getColor() returns the colors based on the system or theme colors.

The getColor() method always returns RGB values or "transparent".

On Edit pages, text color values are not returned.

Text color values are not returned for field types that are not text based, such as check boxes or visual indicators.

getId()

String

Returns the row ID of an associated record based on the associated record field displayed on the screen.

For example, if an Account's Primary Contact field is on the screen, then to return the Primary Contact ID value:

getField("Primary Contact").getId();

For an associated record on a List page:

oraclecrmod.getList().getRow(0).getField("Owner").getId();

The getId() method is supported on Detail, Edit, and List pages. For New pages, it returns null.

The getId() method on a field only works for associated record fields and returns null for other types of fields.

Multi-association fields are not supported, for example, the Users and Contacts fields of Activity.

NOTE:  For fields like Modified that have a user name link and a date, getColor() returns the user name link color. However, setColor() can set the color on both the link and text.

Oracle CRM On Demand JavaScript API Developer's Guide, Release 38 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Legal Notices.