Client Examples

Basic Client Create

Create a basic client, setting the only required property: Client Name.

[
  {
    "Action": "Create",
    "Type": "Replicon.Domain.Client",
    "Operations": [
      {
        "__operation": "SetProperties",
        "Name": "Northwind Inc."
      }
    ]
  }
]

Complete Client Create

Create a client, setting all property values.

[
  {
    "Action": "Create",
    "Type": "Replicon.Domain.Client",
    "Operations": [
      {
        "__operation": "SetProperties",
        "Name": "Tradewinds Ltd.",
        "Code": "TWL",
        "Comments": "Tradewinds monitors trends in global trade",
        "Address1": "100 Commerce Lane",
        "Address2": "Unit 1",
        "City": "Freeport",
        "StateProvince": "MA",
        "ZipPostalCode": "50505",
        "Country": "USA",
        "Telephone": "+1 555 555 1111",
        "Fax": "+1 555 555 2222",
        "Website": "http://www.tradewinds.huh",
        "Disabled": false,
        "DefaultBillingRateAmount": 150,
        "DefaultBillingRateDescription": "Standard trade report rate",
        "DefaultBillingRateCurrency": {
          "__type": "Replicon.Domain.Currency",
          "Identity": "1"
        }
      }
    ]
  }
]

Query All Clients

Query for all clients in the system. This query takes no arguments.

[
  {
    "Action": "Query",
    "QueryType": "ClientAll",
    "DomainType": "Replicon.Domain.Client",
    "Args": []
  }
]

Query Specific Client by Id

Query for the specific client with ID #2. This query takes a single argument: an array of client IDs to find.

[
  {
    "Action": "Query",
    "QueryType": "ClientById",
    "DomainType": "Replicon.Domain.Client",
    "Args": [
      [
        2
      ]
    ]
  }
]

Query Specific Client with Relationships Loaded

Query for client with ID #2 and load the DefaultBillingRateCurrency relationship. The load clause can be added to any query to load specified relationships.

[
  {
    "Action": "Query",
    "QueryType": "ClientById",
    "DomainType": "Replicon.Domain.Client",
    "Args": [
      [
        2
      ]
    ],
    "Load": [
      {
        "Relationship": "DefaultBillingRateCurrency"
      }
    ]
  }
]

Query Specific Client by Exact Name

Query for any clients named "Northwind Inc.".

[
  {
    "Action": "Query",
    "QueryType": "ClientByName",
    "DomainType": "Replicon.Domain.Client",
    "Args": [
      "Northwind Inc."
    ]
  }
]

Query Clients by Partial Name

Query for all clients with name containing "win". The first argument to the query is the string to match, and the second argument defines whether to support a partial match (e.g. if this is set to "true", "win" returns "Northwind Inc." and "Tradewinds Ltd.").

[
  {
    "Action": "Query",
    "QueryType": "ClientByPartialName",
    "DomainType": "Replicon.Domain.Client",
    "Args": [
      "win",
      true
    ]
  }
]

Query Client by Code

Query for clients with client code "TWL".

[
  {
    "Action": "Query",
    "QueryType": "ClientByCode",
    "DomainType": "Replicon.Domain.Client",
    "Args": [
      "TWL"
    ]
  }
]

Query Expense Clients by Current User

Query Expense Clients by Current User

[
  {
    "Action": "Query",
    "QueryType": "ExpenseClients",
    "DomainType": "Replicon.Domain.Client",
    "Args": []
  }
]

Query Expense Clients by User Id

Query Expense Clients by User Id

[
  {
    "Action": "Query",
    "QueryType": "ExpenseClientsByUser",
    "DomainType": "Replicon.Domain.Client",
    "Args": [
      {
        "__type": "Replicon.Domain.User",
        "Identity": "2"
      }
    ]
  }
]

Update Client

Change a client's address and billing currency.

[
  {
    "Action": "Edit",
    "Type": "Replicon.Domain.Client",
    "Identity": "2",
    "Operations": [
      {
        "__operation": "SetProperties",
        "Address1": "404 Lost Way",
        "Address2": "Unknown Acres",
        "City": "That Place",
        "StateProvince": "Desert Island",
        "ZipPostalCode": "404",
        "Country": "Mysteria",
        "DefaultBillingRateAmount": 100,
        "DefaultBillingRateDescription": "Rate for the lost",
        "DefaultBillingRateCurrency": {
          "__type": "Replicon.Domain.Currency",
          "Identity": "2"
        }
      }
    ]
  }
]

Set Client UDF Values

Set user defined field values (Billing Mode, Referrals, and Last Service Date) for different user defined field types (text/dropdown, number, and date).

[
  {
    "Action": "Edit",
    "Type": "Replicon.Domain.Client",
    "Identity": "2",
    "Operations": [
      {
        "__operation": "SetUdfValues",
        "Billing Mode": "Automatic",
        "Referrals": 2,
        "Last Service Date": {
          "__type": "Date",
          "Year": 2010,
          "Month": 7,
          "Day": 9
        }
      }
    ]
  }
]

Query Timesheet Clients by User Id

Query Timesheet Clients by User Id

[
  {
    "Action": "Query",
    "QueryType": "TimesheetClientsByUser",
    "DomainType": "Replicon.Domain.Client",
    "Args": [
      {
        "__type": "Replicon.Domain.User",
        "Identity": "2"
      }
    ]
  }
]