In this blog, I explain how to add employee, get employee and update employee using the QuickBooks API v3 in c#.
An Employee object represents a person working for the company.
SAMPLE OBJECT
{ "Employee": { "SyncToken": "0", "domain": "QBO", "DisplayName": "Bill Miller", "PrimaryPhone": { "FreeFormNumber": "234-525-1234" }, "PrintOnCheckName": "Bill Miller", "FamilyName": "Miller", "Active": true, "SSN": "XXX-XX-XXXX", "PrimaryAddr": { "CountrySubDivisionCode": "CA", "City": "Middlefield", "PostalCode": "93242", "Id": "116", "Line1": "45 N. Elm Street" }, "sparse": false, "BillableTime": false, "GivenName": "Bill", "Id": "71", "MetaData": { "CreateTime": "2015-07-24T09:34:35-07:00", "LastUpdatedTime": "2015-07-24T09:34:35-07:00" } }, "time": "2015-07-24T09:35:54.805-07:00" }
The minimum elements to create an employee are listed here.
{ "GivenName": "Bhavdip", "PrimaryAddr": { "CountrySubDivisionCode": "CA", "City": "Middlefield", "PostalCode": "93242", "Id": "50", "Line1": "45 N. Elm Street" }, "PrimaryPhone": { "FreeFormNumber": "408-525-1234" }, "FamilyName": "Talaviya" }
Now I add the employee using the C# code.
Employee _employee = new Employee(); employee.GivenName = "Bhavdip"; employee.FamilyName = "Talaviya"; TelephoneNumber _Mobile = new TelephoneNumber(); Mobile.FreeFormNumber = "408-525-1234"; employee.Mobile = _Mobile; PhysicalAddress PrimaryAddr= new PhysicalAddress(); PrimaryAddr.CountrySubDivisionCode = "CA"; PrimaryAddr.PostalCode = "94030"; PrimaryAddr.Country = "U.S.A"; PrimaryAddr.Line1 = "29834 Mustang Ave."; PrimaryAddr.City = "Millbrae"; employee.PrimaryAddr= PrimaryAddr; employee.Active = true; Employee_employeeAdded = dataService.Add(employee);
you get the added employee response in the _employeeAdded so you can see or update to your DB.
Select * From employee
you can also make the query as you like below :
get employee by LastUpdatedTime: select * from employee where Metadata.LastUpdatedTime > ‘2015-03-01’
get employee by ID: Select * From employee where Id = ‘1’
You need Realmid and AccessTocken for the get any data from the QuickBooks.
Now I get the all employee using the C# code.
var realmid="add here your realm id"; var AccessTocken="add here your AccessTocken"; QueryService<Employee> QueryService = new QueryService<Employee>(GetContext(realmid, AccessTocken)); List<Employee> _getEmployee = QueryService.ExecuteIdsQuery("Select * From Employee").ToList();
you get the employee response in the _getEmployee variable so you can store this data into your DB.
In update employee, you need Quickbooks inserted Id and also SyncToken which get when the employee added.
ATTRIBUTES
Id
SyncToken
Now I update the employee using the C# code, here I update the only family name for the employee.
Employee emp = new Employee(); emp.FamilyName = "patel"; emp.Id = "1"; emp.SyncToken = "1"; Employee _employeeUpdated = dataService.Update(emp);
you get the updated employee response in the _employeeUpdated so you can see or update to your DB.
you can not delete the employee in QuickBooks online, you can update this employee as In-active like below:
emp.Active = false;
so In this blog, I explained add employee, update employee and also get an employee.
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
View Comments
How to add the data available in the _employeeAdded into the database? Can you please share the code? I am stuck at this point as data is not getting inserted.
How to add the values from _employeeAdded into the DB in the online QuickBooks? Can you please share the sample code as I am a newbie