1. How to map customers? (PlugSales)
Adding new customers:
Section titled “Adding new customers:”To add new customers through the application, you must use the following field:
This SQL query will always be executed when a new customer is registered in the PlugSales application.
*In this field you can use any SQL command that inserts data into your database.
For the insertion of the new customer to be carried out correctly, SQL must receive the parameters sent from the application. The SQL command must be described in the same way as it is done in your database. To use the parameters, you must always use them between relatives (Ex: [NAME]). See the parameters:
Parameters sent by the application:
Section titled “Parameters sent by the application:”*Attention, PlugBot considers your customer table to be AUTOINCREMENT for the identification field (ID /NUMBER /CODE). If your table does not have an increment, your query must contain an automatic increment of the identifier, or you must use a PROCEDURE that performs the increment and insertion.
- PEOPLETYPE*(text)*
- This parameter returns the customer type “Individual” or “Legal Entity” depending on the seller’s selection.
- NAME (text)
- This parameter returns the company name or name of the customer that was registered in the application.
- CPFCNPJ (text)
- This parameter returns the CPF or CNPJ of the customer registered in the application.
- EMAIL (text)
- This parameter returns the customer’s email registered in the application.
- PHONE (text)
- This parameter returns the customer’s phone number registered in the application.
- CEP (text)
- This parameter returns the zip code of the customer registered in the application.
- CITY (text)
- This parameter returns the customer’s email registered in the application.
- UF (text)
- This parameter returns the UF of the client registered in the application.
- ADDRESS (text)
- This parameter returns the customer address registered in the application.
- NUMBER (text)
- This parameter returns the customer’s home number registered in the application.
- NEIGHBORHOOD (text)
- This parameter returns the customer’s neighborhood registered in the application.
- COMPLEMENT (text)
- This parameter returns the client complement registered in the application.
- IDUSER (whole number)
- This parameter returns the ID of the user who registered the customer in the application.
- STATE REGISTRATION (text)
- This parameter returns the first name or surname of the customer registered in the application.
- PRICE TABLE (whole number) (OPTIONAL)
- If using PRICE TABLE, this field returns the ID of the price table related to the customer, selected when the customer registered.
See below an example of SQL for inserting a new CUSTOMER:
Example in a MySQLINSERT INTO CLIENT database (person_type, name, CNPJ, email, telephone, zip code, city, UF, address, user, complement, number, neighborhood, insc_est) VALUES (‘[TYPEPESSOA]’, ‘[NAME]’, ‘[CPFCNPJ]’, ‘[EMAIL]’, ‘[PHONE]’, ‘[CEP]’, ‘[CITY]’, ‘[UF]’, ‘[ADDRESS]’, ‘[IDUSUARIO]’, ‘[COMPLEMENT]’, ‘[NUMBER]’, ‘[NEIGHBORHOOD]’, ‘[STATE REGISTRATION]’)
* Attention, for parameters of type TEXT(string), they must receive an apostrophe. Example: ‘[NAME]’. It is not necessary for NUMERIC parameters. Note: **if the special characters **’ “ | **, line breaks or emojis are identified in parameters of type texto, they will be removed to avoid conflicts with any means of integration.
Custom Fields (INPUT)
To be able to use custom fields in customer registration, click here.
Mapping Customers
Section titled “Mapping Customers”To map your customers in PlugSales, each customer record must have the following fields:
* Attention, all mandatory fields must return records.
- ID*
- Numeric field of type inteiro.
- Used to identify the customer in the order.
- This field cannot contain identical records.
- All customers must be registered in this field.
- This field will be returned in the order.
- REASON*
- Field texto with the company name or name of the customer.
- FANTASY*- texto field with the customer’s first name or surname.
- CNPJ
- Field texto with the customer’s CNPJ/CPF.
- This field is mandatory, and all customers must contain records in the field.
- ADDRESS
- texto field with the customer’s address.
- PHONE
- Field texto with the customer’s telephone number.
- EMAIL
- texto field with the customer’s email.
- CITY
- Field texto with the customer’s city.
- UF
- texto field with the client’s status.
- SITUATION
- texto field with the client’s situation.
- This field can be used to block customers.
- USER
- Numeric field of type inteiro with the user code linked to the customer.
- The client will only be available to the related user.
- ADD CUSTOM FIELD
- Using custom fields you can enter more information about your CUSTOMER.
- In this field it is necessary to determine the typing (Monetary or String).
- In this field it is necessary to define whether or not this information should be sent to the order PDF.
- A field in your database must be related.
- The record in this field will be displayed along with the CUSTOMER information. Learn more about how ‘Add custom field’ works. Note: For these fields to be reported correctly, we recommend creating a specific view and entering it in the PlugBot panel.
Read: Creating a view to map customers
To start configuring the products, define the interval at which PlugBot should synchronize records from your system to your PlugSales.
Note: We recommend using at least 10 minutes
After selecting the Source Tableor entering the SQL Source, click “Load data”.
With the data loaded, you can begin the field mapping process, following the instructions for each field.

## Client blocking:
It is possible to add blocking situations so that the application prevents the registration of orders for customers who are in these situations.
Then, based on the SITUATION** field listed above, you can define which situations you want to block the customer.
Example: If the customer has an INACTIVE record in the SITUATION field, and this is a blocking situation, the customer will be blocked for orders.
See some examples of blocks:
-** INACTIVE** -** UNDER ANALYSIS** -** INACTIVE, BLOCKEDNote:in case of more than one situation, you must separate them with a comma. Note:regardless of upper and lower case letters, that is, Inactive and INACTIVE**are the same thing.
With all fields mapped and configured, click “Save CUSTOMER Settings” at the bottom of the screen.