Class Company
Represents a company.
Syntax
Examples
Company c;
c.load(2); // Loads company with ID = 2
print(c.getValue("primContact"));
c.setValue("name", "SuperOffice");
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
c.save();
Constructors
Company()
Initializes a new instance of the Company class.
Declaration
Company
Examples
Company c;
c.load(2);
Methods
checkFieldRights(String,String)
Checks if the current user has access to the field.
Declaration
Bool checkFieldRights(String field, String fieldRight)
Parameters
Type | Name | Description |
---|---|---|
String | field | The field to check. |
String | fieldRight | Type of access to check for - read or write. |
Returns
Type | Description |
---|---|
Bool | True if the current user has access to the field; otherwise, false. |
Examples
Company c;
c.load(3);
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
checkTableRights(String)
Checks if the current user has access to this company.
Declaration
Bool checkTableRights(String tableRight)
Parameters
Type | Name | Description |
---|---|---|
String | tableRight | Type of access to check for - select, update, or insert. |
Returns
Type | Description |
---|---|
Bool | True if the current user has access to the company; otherwise, false. |
Examples
Company c;
c.load(3);
Bool b = c.checkTableRights("select");
print(b.toString());
findFromDomain(String)
Find and load company object given a domain.
Declaration
findFromDomain(String domain)
Parameters
Type | Name | Description |
---|---|---|
String | domain | Domain of the company. |
Returns
Type | Description |
---|---|
Bool | True if successfully loaded; otherwise, false. |
Examples
Company c;
c.load(2); // Loads company with ID = 2
print(c.getValue("primContact"));
c.setValue("name", "SuperOffice");
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
c.save();
getFormattedAddress()
Gets the formatted company address.
Declaration
NSLocalizedField[][] getFormattedAddress()
Returns
Type | Description |
---|---|
NSLocalizedField[][] | The formatted company address. |
Examples
Company c;
c.load(2); // Loads company with ID = 2
print(c.getValue("primContact"));
c.setValue("name", "SuperOffice");
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
c.save();
getValue(String)
Gets a String with the value of a given column.
Declaration
String getValue(String colName)
Parameters
Type | Name | Description |
---|---|---|
String | colName | The column to get data from. |
Returns
Type | Description |
---|---|
String | A string value of the given column. |
Remarks
Possible colNames:
- id: Integer, The primary key (auto-incremented)
- primContact: Integer, The ID of the customer who is the primary contact for this company customer.id
- name: String, The name of the company
- note: String, A freetext field for various notes about this company
- phone: String, The company's phone number
- fax: String, The company's faxnumber
- adr: String, The company's address
- priority: Integer, The reference to the default priority for this company. NULL or -1 if not set. ticket_priority.id
- deleted: Bool, A boolean telling if the company is deleted
- language: Integer, The reference to the default customer language for this company. NULL or -1 if not set. cust_lang.id
- ourContact: Integer, The customer's primary contact ejuser.id
- extTable: Integer, The reference to the external table if this is a cached entry. NULL or -1 if not. ext_table.id
- extKey: String, The primary key for the cached entry in the external datasource.
- extLastCached: DateTime, When the cached entry was last updated.
- domain: String, A display version of the company_domain table for this company.
- x_* The extrafield with the given database field name.
Examples
Company c;
c.load(3);
print(c.getValue("name"));
load(Integer)
Load object with values from company with given ID.
Declaration
Bool load(Integer id)
Parameters
Type | Name | Description |
---|---|---|
Integer | id | The ID of the company. |
Returns
Type | Description |
---|---|
Bool | True if successfully loaded; otherwise, false. |
Examples
Company c;
Bool b = c.load(3);
print(b.toString());
loadFromAgentAndKey(Integer,String)
Loads a company based on agent ID and external key.
Declaration
Bool loadFromAgentAndKey(Integer agent, String key)
Parameters
Type | Name | Description |
---|---|---|
Integer | agent | The ID of the agent that owns this company. |
String | key | The external key of this company. |
Returns
Type | Description |
---|---|
Bool | True if successfully loaded; false if the company does not exist. |
Remarks
Loading might overwriting existing values.
Examples
Company c;
c.load(2); // Loads company with ID = 2
print(c.getValue("primContact"));
c.setValue("name", "SuperOffice");
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
c.save();
save()
Saves the object and returns its ID.
Declaration
Integer save()
Returns
Type | Description |
---|---|
Integer | The company ID. |
Examples
Company c;
c.load(2); // Loads company with ID = 2
print(c.getValue("primContact"));
c.setValue("name", "SuperOffice");
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
c.save();
setFormattedAddress(NSLocalizedField[][])
Sets the formatted address for a company.
Declaration
Void SetFormattedAddress(NSLocalizedField[][] name)
Parameters
Type | Name | Description |
---|---|---|
NSLocalizedField[][] | name | The new address. |
Returns
Type | Description |
---|---|
Examples
Company c;
c.load(2); // Loads company with ID = 2
print(c.getValue("primContact"));
c.setValue("name", "SuperOffice");
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
c.save();
setValue(String,String)
Sets a value in a column of a company.
Declaration
Void SetValue(String colName, String value)
Parameters
Type | Name | Description |
---|---|---|
String | colName | Column name. |
String | value | Value that should be stored. |
Returns
Type | Description |
---|---|
Remarks
Possible column names
- id: Integer, The primary key (auto-incremented)
- primContact: Integer, The ID of the customer who is the primary contact for this company customer.id
- name: String, The name of the company
- note: String, A freetext field for various notes about this company
- infoText: the same as note (From 7.x)
- phone: String, The company's phone number
- phone/formattedNumber: String (From 7.x)
- fax/formattedNumber: String (From 7.x)
- fax: String, The company's faxnumber
- adr: String, The company's address (From 7.x setting address with adr is no longer supported. Attempting to do so, will result in a GeneralException. Use NetServer instead)
- priority: Integer, The reference to the default priority for this company. NULL or -1 if not set. ticket_priority.id
- deleted: Bool, A boolean telling if the company is deleted
- language: Integer, The reference to the default customer language for this company. NULL or -1 if not set. cust_lang.id
- ourContact: Integer, The customer's primary contact ejuser.id
- ourSalesContact: Integer, The sales contact for this company. (From 7.x)
- supportAssociateId: String, Set the support associate id. Supports both integer and the username. (From 7.x)
- primContact: Integer, The customer's primary contact customer.id
- extTable: Integer, The reference to the external table if this is a cached entry. NULL or -1 if not. ext_table.id
- extKey: String, The primary key for the cached entry in the external datasource.
- extLastCached: DateTime, When the cached entry was last updated.
- domain: String, A display version of the company_domain table for this company.
Examples
Company c;
c.load(3);
Bool b = c.checkTableRights("select");
print(b.toString());
c.setValue("name", "Test");
toParser(Parser)
Puts a lot of fields into the input parser.
Declaration
toParser(Parser parser)
Parameters
Type | Name | Description |
---|---|---|
Parser | parser | The parser to put the field-value-pairs to. |
Remarks
Fields that will be loaded:
- company.id: The ID
- company.name: The name
- company.note: The note
- company.domain: The domain
- company.phone: Phone number
- company.fax: Fax number
- company.adr: The address
- company.ourContact: The ID of the user that is this company's contact
- company.primaryContact.id: The ID of the customer that is this company's primary contact
- company.primaryContact.email: The email address of the customer that is this company's primary contact
- company.extraFieldName: The name of the extrafield, (not x_fieldname)
Examples
Company c;
c.load(2); // Loads company with ID = 2
print(c.getValue("primContact"));
c.setValue("name", "SuperOffice");
Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
c.save();