Automatically Import Organizations from PSA if Active Clients
Tim McClain
Similar to the way Connectwise to IT Glue handles the automatic import I would like to have organizations that meet certain conditions like a name of "Managed Services Client" and marked as "Active" and create the organization in Rewst.
Log In
Nolan Morford
Hey Tim,
Sharing an approach that works for us, in case it helps there too:
Use the
/finance/agreements
endpointOne of the best ways to consistently identify relevant organizations from CWM is by using the
getFinanceAgreements
operation from the /finance/agreements
endpoint. This will allow you to request a list of agreements, ideally with a primary filter condition of agreementStatus = "Active"
to only return data for companies that have active agreements. It's worth mentioning the agreementStatus
field only allows values of Active
, Cancelled
, Expired
, or Inactive
.Extract the
company
fieldAfter filtering for active agreements (with or without secondary filters) you can extract the
company
field from each, which references #/components/schemas/CompanyReference
from the CWM REST API and includes the key company metadata that can be used in your process: id
, name
, and identifier
. It's important to note that multiple agreements can reference the same company, so you'll want to use some jinja afterwards to remove duplicate company items before further processing (unique based on id
).Notes
Using the
/finance/agreements
endpoint is an efficient approach here because you're not querying the more resource-heavy /company
endpoint directly and are only requesting active agreements
in order to return active companies
, which helps keep things optimized by reducing the amount of data to process while removing the potential for human error with CompanyTypes, CompanyStatuses, etc (hey, we all do it
). To access the CWM developer links above, you'll need to sign in to the ConnectWise Developer Network first. To use the CWM /finance/agreements
endpoint, your "rewst" api member will need to have Inquire = "All"
permissions, at minimum, for the Agreements action in the Finance module of Security Roles.Character limit reached, but I am hoping this gives you a good starting point to explore. If this works for you, it just might help others that cross this path too.
Cheers