The getField
command can be used to retrieve a specific field out of a certain section.
Command
A successful request is comprised of three parts:
Argument | Type | Value |
---|---|---|
command | string | 'getField' |
callback | function | function (data: mixed or null, success) |
parameter | string | API Prefix string + "." (dot) + fieldName |
__gpp('getField', (data,success)=>{console.log("getField successfully executed:" + success);console.log("Value for specified field is: " + data}, 'APIPrefix.fieldName');
function getField_fn(data, success) {
console.log("getField successfully executed: " + success);
console.log("Value for the specified field is: " + data);
}
...
__gpp('getField', getField_fn, 'APIPrefix.fieldName')
Example
A request in the browser console to retrieve the value of the
SharingNotice
field of theU.S. National Privacy
section would be called via:__gpp('getField', (data,success)=>{console.log("getField successfully executed:" + success); console.log("Value for specified field is: " + data)}, 'usnat.SharingNotice');
Response
A successful getField
request will return true
for the success
parameter and the value of the requested field for the data
parameter.
The data parameter may be null
for fields in sections that don't allow accessing the section data object outside an event handler. It may also be null
when the CMP is not yet loaded.