Class UrlField
Stay organized with collections
Save and categorize content based on your preferences.
AI-generated Key Takeaways
-
UrlField is deprecated and the People API advanced service should be used instead.
-
A UrlField represents a URL field within a Contact.
-
Methods are available to get and set the address and label of a UrlField, and to check or set if it is the primary field value.
-
The
deleteUrlField()method is deprecated and should not be used.
Methods
| Method | Return type | Brief description |
|---|---|---|
get | String | Get the address for this field. |
get | Object | Gets the label for this field. |
is | Boolean | Gets whether this is the primary field value. |
set | | Sets the address of this field. |
set | | Sets this field to primary. |
set | | Sets the label of this field. |
set | | Sets the label of this field. |
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| void | Deletes this URL field. |
Detailed documentation
getAddress()
Get the address for this field.
// Logs the address for the 'Home Address' field for contact 'John Doe'. // Can be used similarly for other fields that contain addresses. constcontacts=ContactsApp.getContactsByName('John Doe'); consthomeAddress=contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS); Logger.log(homeAddress[0].getAddress());
Return
String — the address as a string
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getLabel()
Gets the label for this field. This may be a Field, ExtendedField, or a String.
// Logs the label for all the address fields associated with contact // 'John Doe'. This method can be similarly called for any field that has // a label. constcontacts=ContactsApp.getContactsByName('John Doe'); constaddressFields=contacts[0].getAddresses(); for(leti=0;i < addressFields.length;i++){ Logger.log(addressFields[i].getLabel()); }
Return
Object — the label for this field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
isPrimary()
Gets whether this is the primary field value.
// Logs whether or not the first address field associated with contact // 'John Doe' is labeled as primary. This method can be similarly called // for any field. constcontacts=ContactsApp.getContactsByName('John Doe'); constaddressFields=contacts[0].getAddresses(); Logger.log(addressFields[0].isPrimary());
Return
Boolean — whether this is primary
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
setAddress(address)
Sets the address of this field.
// Sets the address for the 'Home Address' field for contact 'John Doe'. // Can be used similarly for other fields that contain addresses. constcontacts=ContactsApp.getContactsByName('John Doe'); consthomeAddress=contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS); homeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');
Parameters
| Name | Type | Description |
|---|---|---|
address | String | the new address |
Return
— this field, useful for chaining(削除) Url
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
setAsPrimary()
Sets this field to primary.
// Sets the first address field associated with contact 'John Doe' // as primary. This method can be similarly called for any field. constcontacts=ContactsApp.getContactsByName('John Doe'); constaddressFields=contacts[0].getAddresses(); addressFields[0].setAsPrimary();
Return
— this FieldValue for chaining(削除) Url
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
setLabel(field)
Sets the label of this field.
// Sets the label to 'Work' for the first address field associated // with contact 'John Doe'. This method can be similarly called for any // field that has a label. constcontacts=ContactsApp.getContactsByName('John Doe'); constaddressFields=contacts[0].getAddresses(); addressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);
Parameters
| Name | Type | Description |
|---|---|---|
field | | the new standard label |
Return
— this FieldValue for chaining(削除) Url
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
setLabel(label)
Sets the label of this field.
// Sets the label to 'Apartment' for the first address field associated // with contact 'John Doe'. This method can be similarly called for any // field that has a label. constcontacts=ContactsApp.getContactsByName('John Doe'); constaddressFields=contacts[0].getAddresses(); addressFields[0].setLabel('Apartment');
Parameters
| Name | Type | Description |
|---|---|---|
label | String | the new label for this field |
Return
— this field, useful for chaining(削除) Url
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
Deprecated methods
(削除) deleteUrlField() (削除ここまで)
deleteUrlField() (削除ここまで)Deprecated. This function is deprecated and should not be used in new scripts.
Deletes this URL field.
// Retrieves and deletes the Blog URL field for contact 'John // Doe' constcontacts=ContactsApp.getContactsByName('John Doe'); consturlFields=contacts[0].getUrls(ContactsApp.Field.BLOG); urlFields[0].deleteUrlField();
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds