Dynamics 365 change tracking many to many relationship - dynamics-crm

Has anyone tried using change tracking for many to many relationships? Since change tracking is enabled at the entity level, I'm not sure how to set it up (if it's possible). I'm using some m:m relationships in the portal and would like the data to be properly reflected.

Unfortunately, like you said, change tracking has to be enabled in entity level and Native many to many relationship created intersect entity is not exposed to customize. So no way to do that.
If it’s Manual many to many relationship (1:N from either side) then you get an intersect entity to enable change tracking.
Edit:
Noticed that the native N:N relationship also creates a table in database (which is not visible anywhere) & getting synced using Data Export Service without need to enable “change tracking”.

Related

Create database via API based on Laravel migration file

I have a school management system built using Laravel and uses MySQL for database. In this system I want to be able to create a separate database for each school, how can I do that programmatically or via API
You are probably heading into an architecture called Multi-Tenant Architecture (MTA), and based on my experience, you can do that using one of these options:
External Library, I used Tenancy before for creating an MTA app, it is pretty awesome.
Manually, which has a lot of stuff to cover, but it is the easiest way to understand. For this option, basically you just add the foreign key to all of the object that you want to separate. For example, your database has schools and students tables, then schools is your tenant in MTA, which is the one that you want to make a different database, then students is the item that you want to keep separately in each of the database, then you need to add school_id to the students table.
Your wanted answer, which is mentioned here. I personally do not recommend this because this is just does not make sense that you called an Artisan command when your application is running programmatically.
If you have the time to research into MTA, go for the first option. If you have some time, second option is great, and if you don't have time at all, you can take the third option.

Does RoomDB supports dropAllTables() and createAllTables()?

GreenDAO supports DaoMaster.dropAllTables() and DaoMaster.createAllTables(). I'm looking for similar functionality in RoomDB. Does RoomDB supports this functionality ??
The use-case for this functionality is, when the user tries to login with new mobile number to my app, i want to clear the data of old login number by showing a warning dialog message and allow login with new number.
Room supports dropping and creating tables only during a migration between schema versions.
You can gain access to the underlying SupportSQLiteDatabase via RoomDatabase.getOpenHelper().getReadableDatabase(). With that, you can use execSQL() to execute SQL statements, include table dropping and creating.
But doing so is not consistent with the intended use of Room and is not safe. It will very likely break the InvalidationTracker used to notify observers of changes to managed tables.
From your use-case, it seems like rather than dropping and recreating the tables, all you need to do is clear them by deleting all entries.

User cannot see any custom and some system entities only in advanced find in Dynamics CRM 2016

I have a weird issue in an organization i have recently taken over, and briefly what it is, is that no users can do advanced find on any custom entities, and on most of the system entities. The entities are simply not there to be selected for advanced find.
Issue was first reported as, no user having permissions to run reports. After which i have thoroughly checked the reporting services permissions, execution service accounts, etc. And all of them seems to be configured fine.
After this i have noticed that when i try to do an advanced find, i do not see any of the custom or system entities. In the advanced find, only some system ones. Now, when accessing through the sitemap, these custom and system entities are accessible and you can do things like edits of fields and export to excel. But from advanced find nothing.
I have considered this to be a security roles issue, although I have System Admin and System Customizer roles, and the user must not have any permissions on an entity so they don't appear in the advanced find, but still the entities are not in the advanced find. I have also tried exporting all roles from a working organization to the one with the issue. Nothing changes.
Another issue with this is that user cannot do Bulk Deletion, as advanced find queries are used there as well.
Next thing that popped in my mind to check is the CAL user setting. So i disabled all users in the system, and left only mine with access mode READ-WRITE, License Mode Professional. Again, nothing.
Additional Information 1:
I transferred over the problematic organization to a new Server, same thing. This led me thinking that repair would not do much, as it is organization related, and not server related. I have also installed SP1 on the server, which passed fine, but issue remained. There is another organization on the same server, with the same solution/s installed which doesn't have the problem. So it is organization specific.
Does anyone have any suggestions how someone could have messed this up in a potentially unsupported way, as this unsupported is the only thing that comes to mind next?
Yes, like almost every time you post a question on Stack Overflow, you suddenly get much more creative and get additional ideas on how to troubleshoot and approach your problem.
Since i checked the customization.xml file for any settings containing 'advancedfind' and didn't find any there, i tried searching in the database.
I did a sql query searching all columns, for their names, in the CRM organization database and found out the IsValidForAdvancedFind flag in the Entity and Relationship Metadata Tables.
For all entities not appearing in Advanced find, this was set to 0, so when you set this flag for an entity and its relationship to '1', the entity appears in the advanced find.
Now, there is an extra problem I encountered here, is that for most of the records in the Entity and Relationship tables, for the same entity, relationship name, there are two rows for some entities and relationships. At the moment this is still under investigation.
Update/Edit 2
The extra problem encountered was confirmed that both of the records from an entity or relationship in a the two tables, reflected the same value in the
IsValidForAdvancedFind flag in both rows for each entity or relationship. The extra row had most probably appeared after the update was installed. So setting the flag to 1 in both rows didn't cause a problem.
Any one that might be looking at this resolution, please make a back up of your database before proceeding with this fix, and do extensive testing before doing it on production.
End Update/Edit 2
The FUN thing in all this, is that this modification directly in the DB, an UNSUPPORTED one, was done by a Microsoft Partner. Seems passing certificates to become a partner, doesn't fill in some blanks on how to customize Dynamics. Anyway...

Multiple programs updating the same database

I have a website developed with ASP.NET MVC, Entity Framework Code First and SQL Server.
The website has entities that each have a history of statuses that we defined (NEW, PACKED, SHIPPED etc.)
The DB contains a table in which a completely separate system inserts parcel tracking data.
I have to read this data tracking data and, following certain business rules, add to the existing status history of my entities.
The best way I can think of is to write an independent Windows service to poll the tracking data every so often and update my entity statuses from that. However, that makes me concerned about DB concurrency issues.
Please could someone advise me on the best strategy for this scenario?
Many thanks
There are different ways to do it. It also depends on the response time you need. If you need to update your system as soon as the tracking system updates the record then a trigger is the preferred way. Alternative way is to schedule a job which will run every 15/30mins and sync the 2 systems.
As for the concurrency issue you can use a concurrency token field. Entity framework has support for this.

Multi Tenancy and User Definable Forms

We are designing our new product, which will include multi-tenancy. It will be written in ASP.NET and C#, and may be hosted on Windows Azure or some other Cloud hosting solution.
We’ve been looking at MVC and other technologies and, to be honest, we’re getting bogged down in various acronyms (MVC, EF, WCF etc. etc.).
A particular requirement of our application is causing a headache – the users will be able to add fields to the database, or even create a whole new module.
As a result, each tenant would have a database with a different structure to every other tenant using the system. We envisage that every tenant will have their own database, rather than sharing a database.
(Adding fields etc. to the system will be accomplished using a web interface).
All well and good, but the problem comes when creating a data model for MVC. Modifying a data model programmatically to add a field to a table seems to be impossible, according to this link:
Create EDM during runtime?
This is a major headache for us. Even if we don’t use MVC, I think we’d still want to create a data model (perhaps for used with LINQ to SQL).
We’re considering having a table with loads of fields in it, and instead of adding fields to the database we allocate an existing field in the table when the user wants to add a field to his form. Not sure I like that idea, though.
Of course, we don’t have to use MVC or Entity Framework, but it appears to me that these are the kind of technologies that Microsoft would steer us towards for future development.
Any thoughts? I’m assuming that we’re not the first people in the world to consider this idea of a user-customisable application.
I'd make sure that you have fully explored the option of creating 'Name-Value Pair' type tables as described here http://msdn.microsoft.com/en-us/library/aa479086.aspx#mlttntda_nvp
before you start looking at a customizable schema. Also don't forget that you are going to have to grant much higher permissions to your sql accounts in order for them to create tables on the fly.
A customizable schema means that your sql accounts will also need much higher permissions. It wouldnt be advisable to assign these higher permissions to a tenants account, but to a separate provisioning account which can perform these tasks.
Also before investing effort into EF - try googling 'EF Vote of No Confidence'. It was raised (i believe) mainly in reaction to earlier versions but its definately worth reading up on. nHibernate is an alternative worth investigating.
Just off the top of my head it sounds like a bad idea to allow users to change the database schema. I think you are missing a layer of abstraction. In my mind, it would be more correct to use the database to hold data that describes the format of a customer's data. The actual data would then be saved in a text column as xml, including version information.
This solution may not fit your needs, but I don't know the details of your project. So just consider it my 5 cents.
Most modern SQL databases today supports the 'jsonb' type for key/value storage as a field. Other types (hstor for postgres) exists too. Forget about XML, that's yesterday and no application with respect for itself implements XML unless it is for importing/converting old data.

Resources