> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and update customers

> How to create and update customers with CRMScript.

## Void setValue(String field, String value)

Sets a named field to the given value. Look up names in the reference section down below, or check out the [class reference][1].

<Note>
  Both parameters are strings! Remember to use quotes even for IDs.

  You must call `save()` after setting all applicable values to actually create or update the customer.
</Note>

```crmscript theme={null}
Customer c;
c.setValue("name", "John");
c.save();
```

## Void removeEmail(String email)

Removes the email address from the customer.

<Note>
  You must call `save()` to do the action.
</Note>

```crmscript theme={null}
Customer c;
c.load(4);
c.removeEmail(duplicate@superoffice.com");
c.save();
```

## Integer save()

Saves a new or updated customer and returns its ID.

* If the ID is set before calling `save()`, it's an update.
* If the ID is empty, it's a create.

```crmscript theme={null}
Customer c;
c.setValue("firstname", "Sarah");
printLine(c.save().toString());
```

## Integer save(String p\_gdprSourceKey)

A variant of `save()` that includes the source key for the *StoreAndProcess* consent. These keys can be found in the consent system.

## Reference

### Frequently used values

| Parameter              | Db field         | Description                                                                           |
| :--------------------- | :--------------- | :------------------------------------------------------------------------------------ |
| firstname              | firstname        | The first name of the person                                                          |
| lastname               | lastname         | The last name of the person                                                           |
| title                  | title            | Title                                                                                 |
| person\_number         | person\_number   | Alphanumeric ID                                                                       |
| phone                  | phone            | Phone number                                                                          |
| username<br />password |                  | For the external web                                                                  |
| email                  | Email            | 1 or more                                                                             |
| company                | contact          | The ID of the related company                                                         |
| priority               | ticketPriorityId | The ID of the customer's priority                                                     |
| language               | cust\_lang       | The ID of the default customer language for this company.<br />NULL or -1 if not set. |

### Connected persons

| Parameter          | Db field           | Description                                                                                |
| :----------------- | :----------------- | :----------------------------------------------------------------------------------------- |
| ourContact         | associate\_id      | The ID (`ejuser.id`) or username of the internal employee handling sale to this company    |
| supportAssociateId | supportAssociateId | The ID (`ejuser.id`) or username of the internal employee handling support to this company |

For a complete list of fields, see the [database reference][2].

[1]: /en/automation/crmscript/reference/CRMScript.Native.Customer#setvaluestringstring

[2]: ../../../../database/tables/person


## Related topics

- [Create and update customers](/en/automation/crmscript/howto/contact/create-user.md)
- [Create and update requests](/en/automation/crmscript/howto/request/create.md)
- [Create Or Update User Candidate](/en/api/reference/restful/agent/person_agent/create-or-update-user-candidate.md)
- [Create and update companies](/en/automation/crmscript/howto/company/create-company.md)
- [Create and update messages](/en/automation/crmscript/howto/request/add-message.md)
- [SuperOffice.WebApi.Agents.PersonAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.PersonAgent.md)
