I have two entities with an N:N relationship. For 1 entity instance I have over 500 relationships to the other entity. They are represented on the form for the 1st entity in a sub-grid. I need to remove these 500 relationships and rebuild them.
On the ribbon there is a button to remove 1-to-several selected relationships, but if I use it in this case, 500 links would take a long time to process manually.
Is there a more efficient alternative?
If you are looking for a one time solution I suggest going into SQL server and deleting the relevant records from the bridge table (not supported but very efficient).
If you need a customer facing solution you could create a plugin that disassociates all records from a selected entity and have a "Disassociate All" button on the form or a workflow that triggers it.
Related
I am working on an asset tracking system that also manages the concept of "projects". The users of this application perform maintenance activities on their customer's assets, so they need an action log where actions on an asset start life as a task in a project. For example, "Fix broken frame" might be a task where an action would have something like "Used parts a, b, and c to fix the frame" with a completed time and the employee who performed the action.
The conceptual data model for the application starts with a Customer that has multiple locations and each location has multiple assets. Each asset should have an associated action log so it is easy to view previous actions applied to that asset.
To me, that should all go in one table based upon the logical ownership of that data. Customer owns Locations which own Assets which own Actions.
I believe I should have a second table for projects as this data is tangential to the Customer/Location/Asset data. However, because I read so much about how it should all be one table, I'm not sure if this delineation only exists because I've modeled the data incorrectly because I can't get over the 3NF modeling that I've used for my entire career.
Single table design doesn't forbid you to create multiple tables. Instead in encourages to use only a single table per micro-services (meaning, store correlated data, which you want to access together, in the same table).
Let's look at some anecdotes from experts:
Rick Houlihan tweeted over a year ago
Using a table per entity in DynamoDB is like deploying a new server for each table in RDBMS. Nobody does that. As soon as you segregate items across tables you can no longer group them on a GSI. Instead you must query each table to get related items. This is slow and expensive.
Alex DeBrie responded to a tweet last August
Think of it as one table per service, not across your whole architecture. Each service should own its own table, just like with other databases. The key around single table is more about not requiring a table per entity like in an RDBMS.
Based on this, you should answer to yourself ...
How related is the data?
If you'd build using a relational database, would you store it in separate databases?
Are those actually 2 separate micro services, or is it part of the same micro service?
...
Based on the answers to those (and similar) questions you can argue to either keep it in one table, or to split it across 2 tables.
I'm building a data warehouse for a client where one of the sources of data is a Dynamics AX database. For a given AX table I need to determine if a row has been inserted, modified or deleted, so it can be inserted, updated or deleted in the DW.
With regards to detecting a row having been modified, there appears to be two columns in most AX tables I could use for this purpose, ModifiedDateTime and RecVersion. I have two questions related to these columns:
1) Is the ModifiedDateTime column updated each time a row is updated? If so, is this value updated even if someone updates a row directly in the table, outside of an AX application (such as from a tool like SSMS)?
2) Same questions as above for RecVersion. Also, is the number globally unique across the entire database or just unique for the table?
Is there another alternative I'm not aware of to do what I want to do?
You want to use fields RecId and RecVersion, which are available in all business data tables of AX 2012. RecId is a unique value for each record of a table. RecVersion is 1 after a record has been created and is changed to some number other than 1 everytime the record is changed.
ModifiedDateTime is not a good choice, because it is not available on all tables.
Regarding you question if one of those fields is updated when someone modifies data directly in the AX business database: The answer is no and this is one of the reasons why you absolutely never should do such a thing. Honestly, I've seen several customers crash that did this against the explicit recommendations of their implementation partners. Dynamics AX offers several options to integrate data from other systems, use them and don't try to invent your own.
Regarding your question if RecVersion is globally unique: No. You can use a combination of TableId and RecId to uniquelly identify a record in the AX business database.
As I mentioned in my answer to your question How do I get the location for a row in dbo.CUSTTRANS?, AX comes with a data mart and also has some logic on how to update that based on changes in the business data. I'm not familiar with the details of those updates, but it might be worthwhile investigating them to see if you could reuse them for your purposes.
Some parts of AX 2012 use SQL Server Change Tracking under the hood (e.g. AIF).
Change tracking records deleted record as well, which neither ModifiedDateTime nor RecVersion fields can give you.
I have these entities :
Now, I need to create form to store data.
My problem is, I don't know how to figure out to create those forms.
What I want is a form where I can create a User, and here, I can select a Pack.
When I selected it, a list of Services of the selected pack appears, which I can checked if it is consumed by the User.
More complicated, I need to allow User to have several pack, and same pack is allowed.
It's look like a collection of User_Pack_Service form, but how to keep the Pack of each collection?
Other questions, since Pack_Service is a relation table of ManyToMany relation ship, it complicated the way of add Services in Pack. Is there a way to avoid is creation as entity? (I know I need it to link Pack and Service to User but that result in to many entities for nothing...)
Thanks for your help.
I have a problem I'm trying to solve and I'm really not sure I'm, A) solving it the correct way, and B) able to do what I want.
I have a List Page that is a basically a summary table (transportation table) that has a record in it for every Sales, Purchase, and Transfer order that we will ship. With it is a pile of rolled up information and such that's common from the 3 sources. We use this table on a few list pages and link out to where we need to. This was all built by someone else, but I'm maintaining some parts around it.
I've gotten a request to have the preview pane on a summary table based list page show the lines from the source order. So, if a "sales order" is selected in the grid, show the lines in the preview pane for the "sales order" that was selected. Same for a purchase order and transfer order.
So, my idea, based on pure ignorance and not a ton of experience with Dynamics is that I would just swap out the preview pane based on the source order. The SalesTableListPagePreviewPane for instance has already been updated to work with linking to this summary table. So, I wanted to just change the part reference at runtime.
I've managed to get the FormRun on a list page interaction class from the datasource. I've managed to get a list of the parts via the PartList object. But, I have no idea how to continue on to actually swap out a part reference.
Am I heading down the correct path? Is this a completely wrong Dynamics AX pattern?
Your assumption, that you can dynamically (run-time) change the parts of the form, is wrong.
Listpages especially are quite static, the only code available through interaction classes. It has the benefit that a listpage can be easily deployed on Sharepoint Enterprise Portal.
You have several options:
Use 3 different listpages for each type of transport
Use a common relation table with 3 sub-tables (sales, purchase and transfer)
The last option will enable you to do an outer join on the 3 sub-tables.
The common relation table could be a union view, but I doubt it will perform well.
I want to use ASP.NET Dynamic Data for my next project, but there is a problem a can't manage to solve. In the database we manage authorization on a per-row basis. For example no user is permitted to see all rows of the Contracts table. So there is a Many to Many Relationship between Contracts and Users. So everytime Dynamic Data performs a Select to show all Contracts it has to look into the ContractUsers junction table to see what contracts the current user is permitted to see (filtered by UserID which will be stored in a session variable). Of course these junction tables should be invisible to the users.
By default Dynamic Data returns all rows of a table, so is it possible to customize this behaviour for every query the user performs?
I want to use Dynamic Data together with LINQ to SQL but if this task would much easier to accomplish using Entity Framework I would look into that too.
Thanks for your help and time.
Implementing such a solution in Dynamic Data it will probably require the creation of a custom Entity Template; not really easy but once done it will not require the creation of custom pages just the editing of the page templates.
I think it will be really usefull to check the excellent work on DD done by S.J.Naughton and presented on his blog.
Greetings, F.
You should not use dynamic data because you need full control over querying and manually write all linq queries to add your data level security. If you still insist on dynamic data be aware that you will still write most of pages yourselves and you will only use dynamic templates. You will have to manually define ever data source and correctly pass where condition to filter results based on logged user.
In addition linq-to-sql is not able to hide junction table and entity framework is able to do that only if junction table contains just two FKs for many-to-many relation. If this table contains any other column you want to use in the application you will have to map it as any other entity and dynamic data will show it as an entity.
Dynamic data are technology for quick creation of simple application where you need to provide access to database through web interface but what you describe is not a simple scenario. You need per record authorization which can differ among entity types.