Dynamics AX 2012 R2 - swapping out a preview pane dynamically depending on the record selected - axapta

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.

Related

Can I make this simple app in App maker using calculated models for demonstration purposes?

I am new to Google App maker and I don't have a lot of experience with coding either (sorry :/). Since App maker is marked as low-coding app builder tool, I assumed it was not that hard to make a very simple app with it. However, for me it is.
I need to make a simple app for demonstrations purposes only (so Cloud SQL and other complex database solutions are not in my interest here). I want to make it using calculated models (correct me if I am wrong, calculated models are just temporary solutions, since apps need to have like real databases to be fully functional?).
My app is basically made of 2 datas: 1) Employees and 2) Departments
-> Fields for "Employees" are: First name, Last name and Department.
-> Field for "Departments" is just Department name.
My app is supposed to look like this:
1st page: Table with current employees that has a button to add new employee,
2st page: Table with all department names (e.g. marketing, finance...) that has a button to add new department name,
3rd page: Form that opens when I click on add new employee button in which I can insert their first name, last name and from drop down menu choose department,
4th page: Form that opens when I click on add new department button in which I can insert new department name.
5th page: Form (or some other widget, not sure here) that has option to insert first and last name in order to find out what department that employee is assigned to.
I tried to make first 4 pages, but I end up with forms that I cannot insert anything into them. 5th page is still too much for me.
I hope you understand my struggles and if you know how to do it please share your knowledge. Thank you very much!
Calculated models are kind of like SQL views - they are not necessarily for temporary solutions. Every time you load a calculated model the script you write under that model's datasource is ran. That script usually loads data from an external source (I.e. grabbing stock prices from an API, loading data from an external SQL server, or generating random placeholder data).
You could use the cloud SQL models for this application that you are building - your table with all department names that is supposed to be displayed in the second page could just be a cloud SQL table with one single field for a department name.
I suggest you work through the example apps so you can get a better understanding of how the different components work. Here is a link to one for you to get started.
In short, you're going to create a few models to store information (I suggest using cloud SQL as the calculated models will require code whereas cloud SQL is more plug and play through app maker's bindings). Before you create any pages try to lay out how your databases will look as that will dictate how you set bindings or program your scripts.
Asking to completely make what is essentially a combination of the tutorials already provided by Google is pretty counter intuitive - you should ask more specific questions in regards to implementation.
As for App Maker being a low-code environment, that's only partially true. For very, very simple apps (think glorified forms) you will need only a couple lines of code and can probably do everything through drag-and-drop. However, anything more complicated than a simple form will almost certainly require a good chunk of actual code. There are plenty of resources online to learn Javascript.
You might want to try a google partner like AppSynergy for building stuff like this. It might be overkil for what you need (or maybe not if you intend to build a lot more stuff).

How do I create an Access Form for Table 1 where two Table 1 fields have different data from a single field in Table 2?

I’m absolutely stumped by what I suspect is probably simple for those experienced with Access. I’m brand new to Access (2010) and studying a lot, but unfortunately still confused by many basic concepts. I’m embarrassed to admit that I have spent about 40 hours trying (unsuccessfully) to solve the specific issue below. Please forgive me if I haven’t included enough detail here - I’m not sure how much someone needs to know to address this. I’m happy to edit and/or provide more information.
My question:
How do I create a Form for creating new records / editing existing records in Table1 where two fields in Table1 have different values from a single field in Table2? (I have better detail below)
I want the Form to have all the records from Table1. I have tried many different ways with queries, sub-forms, etc., but can’t pull it off. I’m fairly certain the issue is related to how I address Table2. Ideally, the user would be able to select from dropdowns in the form for the two fields to be updated in Table1.
I am including screenshots of a mockup of my intended Form concept, the object Relationships as I currently have them, the design and datasheet views of Table1 and the design and datasheet views of Table2.
“Table1” above is “t_PEOPLE” in the images while “Table2” is “t_COLORS.”
The object relationship types are currently one-to-many with enforced referential integrity (cascade update related fields) and the join properties are "include ALL records from 't_PEOPLE' and only those records from 't_COLORS' where the joined fields are equal."
I'm happy to send the actual database file if that helps.
I will be very grateful for any guidance - thank you!!
The general approach to this is as follows:
A) If I understand what you're trying to do here, your t_colors table is usually referred to as a Reference table or Lookup table. You need to make one form to add, edit, and delete records in this t_colors table. How the user accesses that form varies. I'll get to that in a minute.
B) The form for your People table needs to have drop down menus for your two color selections. In the dropdown menus' RowSource, you will use a query that looks up values in your t_colors table.
C) Depending what you are using your colors for in t_people, you should consider making a third table with PeopleID and ColorID in it. It would then link to both t_people and t_colors. This would allow you to have multiple colors specified for a single person, and you wouldn't be limited to two. In your People form, you would use a subform for these colors. The subform would probably need to be a datasheet form or a continuous form. If you are using a datasheet form for your people form, then you would need to use a datasheet form for the colors subform.
If the user wants to use a color that isn't already in your t_colors table, you need to give them a way of inserting that color. There are various approaches to this. You could use a union query in the dropdowns RowSource that shows a "" option. If selected you would bring up your Colors form and when they close the colors form you have to requery your dropdown menu. Or you could insert the color for them using VBA when they enter a value that is "Not In List" (an event that Combobox's have).
Please note that the relationships you've defined are not overly helpful or important in this case. Yes, they can be helpful when it comes to using the Update Cascade or Delete Cascade features. But quite truthfully, relationships are basically for programmers, to make sure you get an error if and when referential integrity is violated. Users should never see these errors and properly designed forms will prevent them from occurring. The main reason to use them is that it will force you to design your forms properly by giving you an error when something is wrong, hopefully during your own testing phase of the project.

How to design a Master-Detail Sharepoint 2010 application?

I am in the process of migrating an Access application to Sharepoint 2010 (Enterprise). I would like to use as much Sharepoint "out of the box" funcationality as possible, but I am not opposed to creating some Web Parts.
I am struggling with the design of the "master" table in this application. The application is used to track employee productivity. Daily, about 50 users access the application and basically enter how many "Widgets" they completed that day. There are about 30 types of these "Widgets" and they don't change very often.
The table is designed with individual columns for each of these Widgets. This makes creating the Reports very easy, since all you have to do is select all the fields from the table and dump the result set.
The downside to this approach is obvikously the fact that the schema is "hard coded" (static). I have been asked (in the sake of time) to just normalize the table as much as possible (with CustomerIDs, EmployeeIDs, etc), but keep all the "Widget" fields in there.
I had proposed that we create a Master Detail type relationship where the users would Add a Row (perhaps in a GridView), select the "Widgets" they created that day (from a drop down) and enter their quantity. They generally only make 1 - 3 types of Widgets per day.
The users hate this design and want me to give them a data entry form with ALL the widgets displayed so they can just click in the box (beside the Widget they created that day) and enter their qty and then click save.
I know I could still create this type of Data Entry Form with a Master-Detail type of relationship, but I am pretty sure I couldn't using the SP Out of The Box forms. I would probably have to create a Web Part with a GridView and just populate the GridView with all the possible Wisdgets, then let the user enter the proper Qty(s) beside each widget they are made that day. Once the form is submitted back, I would then have to go through it and find any Qtys that are valid Numbers and add a (child) detail record for that Master record. (The Master Record would contain date, employee, customer, etc. etc.) The "edit" form would also have to work in a similar way.
This is a pretty "ugly" solution and I was looking for an alternative.
If I can't come up with a good alternative (and convice my manager that the code won't be too difficult to maintain or add too much development time to the project to complete it on time) then I will have to bring over this ugly, existing schema with all its wasted space and have "hard coded" stuff thoughout the application. (For instance, if I provide them with a SharePoint View to see how many Widgets of a certain Type were created, I will have to "hard code" all those values in the Drop Down and "Sum" the correct/matching database column. YUK.
Another consideration is the reporting. Right now all the reports just contain a column on the report for every widget. To preserve the look of these reports (if I use a Master/Detail relationship) will require "fancier" queries (Stored Procedures) to buld the proper result set in a "columuar" format. (And I am not sure how I would tackle laying out the SharePoint Views of the data in a similar fashion.)
It certainly would be "easier" to just leave the schema as is (and have all that wasted space in the table). I just hate developing an application that anytime we need to add a new "Widget" to the application, we have to change the application in several places and rebuild. (Although, my manager isn't concerned about that, he just wants to push it out, ASAP...sigh...)
Any help/recommendations on how to do this type of application (specifically how to create the data entry forms and views) in SharePoint would be greatly appreciated!
Shayne
Have you looked at these ideas:
http://paulgalvinsoldblog.wordpress.com/2007/12/24/implementing-master-detail-relationships-using-custom-lists/
http://blogs.msdn.com/b/alexma/archive/2006/04/10/610934.aspx
In my opinion you should be storing the data in list rather than SQL server. If you decide to use SQL server, look at BCS to build Master child view.

Does 1 ViewModel really have 1 View?

its said that 1 ViewModel has 1 View.
1 View is for me a UserControl. What if my UserControl has different areas filled with data from different entities, do I have then several Views and need to build several ViewModels?
e.g: I display in a UserControl 3 entities: customer(listbox),order(datagrid),product(datagrid). Each of those "data areas" has add+remove buttons and textboxes to enter data.
Actually each of those "data areas" are put in its own GRID having so the posibility to set a individual datacontext.
1.) Should I now create 3 ViewModels CustomerVM,OrderVM and ProductVM?
2.) Are those 3 "data areas" seen as an own sort of separated View, although I have not put them in 3 UserControls.xaml files ???
3.) When this one UserControl is inside a TabControl`s tabpage where do I load the 3 entities related data? Inside the MainViewModel? I want to show/load that data only when the user clicks the tabheader.
No, you can do all that in the one viewmodel. The job of the viewmodel is to hold the data for the view, and if necessary transform that data so the view can consume it. There is nothing that says a viewmodel has to hold specific types of information, i.e. there are no rules that state "it may only hold customer info and not order info".
Having said that, there is also no reason why the viewmodel cannot be consumed by several different views (give them all different instances, of course) - this would show that you have a good separation of concerns between your views and viewmodel. Personally, i code my viewmodels so that they have no idea that the view exists. There is also no reason why the view has to consume everything that the viewmodel exposes, although binding a CustomerView to a CustomerOrderProductViewModel is going a little too far.
Edit: let me explain that last paragraph a little more.
Example 1: i have a new V which shows customer information, and i have an existing VM which has customer info AND order info
I would be reluctant to use this VM for this V, because while it does have the client info i need, it has too much info - i'm using the VM out of the context is was originally intended for.
Example 2: i have a VM that contains full client info, like their postal and residential address, their phone numbers, their girlfriend's names*, and a bunch of other client type info. I have a V which shows the client's name, birthday, and maybe two other properties.
I would consider using that VM for that V, this illustrates my point that the V doesn't have to show all the info contained within the VM. This concept becomes more apparent when you change the V (as in, do some maintenance and change the UI of the view, because someone has decided that they want a bunch of fields removed and now they want to represent the client's age as an image) - i can still use the same VM, and just change the V (i could use a ValueConverter to represent the age as an image, thus avoiding a change to the VM).
At what point would i stop using the current ClientViewModel, and write a new one that was more specific to the needs of the modified ClientView?
There is no clear cut answer to that - it depends on the amount of time i have available to do the changes, the amount of time available for testing, and the trade-off in complexity between using a full blown Client object for the VM, and writing a new leaner version of the Client object while still retaining the old one.
*that should be a collection of independant objects incorporated in the client object, but just work with me here it's a made up example :)

Why would one keep several different "displays" in a single page, rather than separate different views in their own page?

When and why would it be a good choice to keep the view of two different sets of information on the same page, and just change what's visible depending on different parameters?
For example, an application I'm working on has three levels of users: Admin, Director and Project Manager. We have a Managers.aspx page which follows this flow of control:
If user is admin, load gridview list of directors with several simple CRUD-like properties. This includes a link for each director that, when clicked, will load a new gridview with several properties of all of the Project Managers belonging to the selected director.
If user is director, load straight to the list of Project Managers that belong to this director, in the exact fashion as described in the second half of the "if user is admin" clause".
This is all done on one Managers.aspx page. Why? What advantage does this hold? When else might this type of situation arise? Personally, this seems like a job for two separate pages. One listing the directors, and another listing the Project Managers.
Thanks in advance :)
As you pointed out, most of the logic for those two requirements is the same: get a list of users, present them in a gridview, apply simple CRUD functions. Doing this as two separate pages would require all that code to be repeated twice, and then kept in sync.
The only real difference between the two screens is which users it shws by default... That's one if-statement of difference in a pageful of code..
As stobor indicates - when you don't want to write the same code twice.
Using the one page solution, the decision about which view to display is made on that one page. If you separate the different views out to different pages, you have to make this decision every time you need to display this data. So rather than one single if/else in Managers.aspx to determine the view, you have multiple if/else statements on multiple pages which are intended to decide whether to load AdministratorManagers.aspx or DirectorManagers.aspx.
Provided your application is robust enough, and you're not doing something stupid like determining which page to show based on a querystring value, there is no real problem using one single page to display different views. In fact, many websites do this. What you don't want to do is use seperate but identical controls for each view, because then you're just going to end up with messy code. It may make sense to create custom controls called 'AdminView' and 'DirectorView' to at least allow you to think of the two views as separate entities, but you'll have to decide for yourself whether this will be a headache-saver or a waste of time.

Resources