Getting all related Contact for an Account entity in Dynamics 365 CRM v9.0 web api - rest

Basically, I'm querying the D365 web API and I'm trying to get all of the related contacts for an account.
Been following this link:
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/query-data-web-api#retrieve-related-entities-by-expanding-navigation-properties
Trying to use $expand but it only will bring over _primarycontactid_value. So just the one primary contact and not everyone that is related to the Account.
It would look something like the following:
/api/data/v9.0/accounts&?select=name&$expand=Contacts(fullname, email)
The only fields in Account that have "contact" in them are:
preferredcontactmethodcode
_primarycontactid_value
address2_primarycontactname
address1_primarycontactname
_tcc_primaryinvoicecontactid_value
_tcc_consultingcontact_value
_tcc_contactlist_value //some custom field that doesn't apparently do anything
_new_foundationcontact_value
_tcc_primaryapcontactid_value
So none of which can be used to look-up all of the contacts... that I know of.
Another way to do it would be to start with the Contact first and then $expand= on the _parentcustomerid_value. But I need to filter on the Account to specify certain accounts that I want... this would just bring over every account and be incredibly slow. I'm not sure there is a way to $filter= on an $expand= value.
So:
How can I query the Account and all the related to Contacts for an Account?
If there is no way, is it possible to use $filter= on and $expand= value?
Trying to keep the amount of queries to a minimum. This could be solved by doing multiple iterative queries, but that will just make it incredibly slow. Or just query everything and piece it together, but that will be slow as well.

Ok, stumbled across the answer: contact_customer_accounts.
Query ends up looking like the following: /api/data/v9.0/accounts&?select=name&$expand=contact_customer_accounts($select=fullname).
As far as I can tell, custom relationships can be used as well, although I have only tested with 1:N types.
Still takes a little while to generate, but works.

Related

Organizing MongoDB database containing different account types

I am working on a react-native app using nodejs and mongodb on the backend. In my app users are able to create multiple accounts and there are different account types (Business, Artist, Venue, etc.). For the most part, each account type has the same data and fields in the database. Things like name, location, website. But it is possible for each account type to have a couple pieces of data specific to that account. My question is, should I simply have one "Account" collection in the database that stores all accounts and has an "accountType" field to differentiate each account?
Initially I thought to do the opposite and store each account type in a separate collection, but I found it made the client code pretty messy as I found myself adding a bunch of if statements to determine things like what api endpoint to make requests to, what components to render, and what screens to navigate to, when in reality, it's really just a couple pieces of data that may change from one account type to another.
It seems like having just one "Accounts" collection with an "accountType" field will greatly simplify the code. But maybe there is something I am missing. If anyone has some insight as to which approach may be better for the situation, or some of the pros/cons of each approach, I'd really appreciate the help! Thanks!
Well, the answer clearly depends on how the documents for different types of accounts differ. But, the idea of going with a single collection is fine, also take a look at the Subset Pattern, it's will give you a fine idea, of how to divide data into different collections, depending on their usage.

What are some patters for designing REST API for user-based platform in AWS?

I am trying to shift towards serverless architecture when it comes to building REST API. I came from Ruby on Rails background.
I have successfully understood and adapted services such as Api Gateway, Cognito, RDS and Lambda functions, however I am struggling with putting it all together in optimal way.
My case is the following. I have a simple user based platform when there are multiple resources related to application members say blog application.
I have used Cognito for the sake of authentication and Aurora as the database service for keeping thing like articles and likes..
Since the database and Cognito user pool are decoupled, it is hard for me to do things like:
Fetching users that liked particular article
Fetching users comments
It seems problematic for me because I need to pass some unique Cognito user identifier (retrieved during authorization phase in API gateway) to lambda function which will then save the database record with an external reference to this user. On the other hand, If I were to fetch particular users, firstly I must fetch their identifiers from my relation database and then request users details from Cognito user pool..I lack some standard ways of accessing current user in my lambda functions as well as mechanisms for easily associating databse record with that user..
I have not found some convincing recommended patterns for designing such applications even though it seems like a very common problem and I am having hard time struggling if my approach is correct..
I would appreciate some comments on what are some patterns to consider when designing simple user based platform and what are the pitfalls of my solution. Any articles and examples will also be very helpfull.
Thanks in advance.
These sound like standard problems associated with distributed, indpependent, databases. You can no longer delegate all relationships to the database and get a result aggregating them in some way. You have to do the work yourself by calling one database, then the other.
For a case like this:
Fetching users that liked particular article
You would look up the "likes" database to determine user IDs of those who liked it, then look up the "users" database to determine user details such as name and avatar.
Most patterns follow standard database advice, e.g. in the above example, you could follow the performance-oriented pattern of de-normalising - store user data such as name and avatar against each "like", as long as you feel the extra storage and burden of keeping it consistent is justified by the reduction in queries (probably too many Likes to justify this).
Another important practice is using bulk queries to avoid N+1 queries. This is what Rails does with the includes syntax, but you may have to do it yourself here. In my example, it should only take two queries because the second query should get all required user data in one go, by querying for users matching the list of user IDs.
Finally, I'd suggest you try to abstract things. This kind of code gets messy fast, so be sure to build a well-encapsulated data layer that isolates application code from dealing with the mess of multiple databases.

QBFC: Custom Reporting - Filter by custom field

In reference to a previous question of mine:
qbfc CustomerQuery based on email address?
Is it possible to create a custom detail report of customers, and using a custom field to "filter" the report. I must admit, I am not really clued in on CustomDetailReports, as I have no need for implementing them, and never had.
It does however look like its supposed to do just what it says, a custom report feeding you info form quickbooks?
What I am attempting to do, is get a list of customers in a detailed report, and filtering that report based on a custom field value. This way I can narrow down my possibilities of customers I need to check for, and get their ListID's or FullNames.
Currently I am returning all the customers using a customerquery, and iterating through them one by one to get the guy I am looking for. This is becoming a slow process as the customers increase.
I can store my own reference in an external DB, and use that to reference an email address to a customer ListID, but I would really like to achieve this with the data stored in Quickbooks only, as per the Quickbooks philosophy of, "Store Data Once"
Before I spend resources on trying to implement a custom report, can something like the above be achieved with Custom Detail Reports?
Thanks in advance.
Is it possible to create a custom detail report of customers, and using a custom field to "filter" the report.
Nope. QuickBooks does not support this.
It does however look like its supposed to do just what it says, a custom report feeding you info form quickbooks?
It will display a custom report, yes... but it won't allow you to filter it by custom fields.
Currently I am returning all the customers using a customerquery, and iterating through them one by one to get the guy I am looking for. This is becoming a slow process as the customers increase.
Have you considered instead caching the customers in your app? That would be much faster. Then you can just periodically run a query against QuickBooks to get customers that have been updated since the last time you ran the query (e.g. incremental sync of data).
I can store my own reference in an external DB, and use that to reference an email address to a customer ListID, but I would really like to achieve this with the data stored in Quickbooks only, as per the Quickbooks philosophy of, "Store Data Once"
My personal experience has been that, unfortunately, the query syntax that QuickBooks allows/uses is too restrictive for that to be realistic.

Method to allow email recipients to change their account information

I'm using SugarCRM Community Edition. I have a bunch of contact information. There are fields I have empty that would like filled. I want each user to be able to fill out a form and fill in those fields.
I'm not sure how to hook each contact into the database. I imagine creating a generic form that somehow hooks into the database using a key. The form/php is not the issue. What is the 'key' and where is the 'door'? I think the door is the SOAP API but I'm not sure. The key, maybe the tracker id?
The only thing I am familiar with as far as interaction between an email campaign and the contact is the campaign 'Tracker'. I know the tracker url with removeme is used for allowing the user to opt out of emails. Is there a way to use this tracker to allow the person to edit their information? I think the answer to this is easy but I need some guidance.
One way of doing this is using the built-in REST api. There are a couple of helpful tutorials out there, here is a link to the one I used for guidance in a similar situation.
You can have a form post the data to your sugar crm's REST gateway, accessible via the url http://localhost/sugar/v2/rest.php.
Although it is quite straightforward to implement, you may want to look at this wrapper class that can be used to maybe keep things cleaner than the hacked up script churned out on the spur of the moment I used in my project.
Last but not least, be sure to glance over the documentation, in the Web Services section you will find more information.
Good-luck

DotNetNuke Multivendor CMS/Store

I need to find a CMS like, set of modules/module which does the following:
give users different logins and access to add their own products.
other users cannot see products which are not added by themselves.
so user A can enter his login and add a set of 5 products. user B can enter his login and add 2 products. user A can never see the 2 products added by B and vice versa.
Any suggestion in already existing modules?
both free and with a price
You can do this with Forms and Lists. Setup the fields you want to collect and then you can use it to only render the logged in users results to them. Also could use XMLdb module or even reports module to query the data out of the database after saved with forms and lists
So no one can see each others products? They are just going to buy from themselves? ;)
Tricky part about users adding their own products is payment. That's why this is not a common store feature. If you allow people to add products, you usually need to allow them to setup their own payment provider to collect the money. And in some cases you (the site owner) would want to take a percentage. Which makes it even more complicated.
I'm not aware of any GOOD DotNetNuke e-commerce module that can do this.
It's very possible Catalook has some feature to do this. They have somehow tried to add every feature ever imagined into their product. But, overall I find it terrible to work with. That is your best bet for trying to get something like that out of the box.
Or try and get one of the open source solutions like NBstore and modify it.