flex query dialog or end user search wizard? - apache-flex

I am hoping there is a component or strategy someone can recommend for presenting the user in a flex (flash builder 4) application a search wizard or query dialog where they are presented a list of fields and can choose one and specify search criteria. This will be used to call a web service and return data to a flex data grid.
For example, if I have a client data grid/database they might see first name, last name, city, state, zip, etc. They could click first name, type a value in a box. Ideally then be able to click additional fields and specify values. Click search and see their results in a datagrid or similar.
I am used to having these helpers in other development/database environments, so I thought I should ask.
I am thinking if I need to create this from scratch, I will either use a combobox? type drop down where they can select multiple items and type a value next to each, OR possibly I will have to create some kind of custom dialog with multiple fields in it. Looking for ideas/thoughts/examples?

Related

How to programmatically link newly created records to a record from another table

Thanks in advance for your advice!
Background
I’m creating a database to track orders placed by customers.
An ‘Orders’ table stores general details about an order like the customer’s name, order date, and delivery-required date.
A separate ‘Order_Items’ table stores the specific items that the customer has ordered.
The is a one-to-many relationship between the ‘Orders’ table and ‘Order_Items’ table, i.e. one ‘Order’ can have many ‘Order_Items’, but each ‘Order_Item’ must be associated with only one ‘Order’.
Current State
Currently, I have a page where the user creates a new ‘Order’ record. The user is then taken to another page where they can create as many ‘Order_Item’ records as are needed for the order.
Desired State
What I would like to achieve is: When a user creates new ‘Order_Item’ records, it automatically allocates the current ‘Order’ record as the foreign key for the new ‘Order_Item’ record.
What I've Tried So Far
Manual Action By The User: One way of establishing the link between an 'Order' and all of its 'Order_Items' would be to add a drop-down widget which which effectively asks the user something like "Which order number do all of these items belong to"? The user's action would then establish the link between the two tables and associate one 'Order' with many 'Order_Items'. However, my goal is for this step to be handled programatically instead.
Official Documentation: I’ve referred to the offical documentation which was useful, but as I'm still learning I don’t really know exactly what to search for. The prefetch feature appeared promising but does not actually establish a link; it just loads associated records more efficiently.
App Maker Tutorials: I found an App Maker tutorial which creates an HR App where a user can create a list of ‘Departments’, then create a list of ‘Employees’, and then link an ‘Employee’ to a ‘Department’. However, in the example app this connection is established manually by the user. In my desired state I would like the link to be established programatically.
Manual Save Mode:
I’ve also tried switching to manual save mode so that the user has to create a draft ‘Orders’ record and then several draft ‘Order Items’ records and then save them all at once. However, I haven’t managed to make this work. I’m not sure whether the failure of this approach is because 1) I’m try to create draft records on more than one table, 2) I’m just not doing it correctly, or 3) I thought I read somewhere that draft records are deprecated.
Other Ideas
I'm very new to this field and am may be wrong, but I have a feeling I may need to use some scripting to establish the link. For example, maybe I could use a global variable to remember which 'Order' the user creates. Then, for each 'Order_Item' I could use the onBeforeCreate event to trigger a script that establishes the link between the 'Order_Item' and the 'Order' that was remembered from the previously established global variable.
Updated Question
Thanks Markus and Morfinismo for your answers. I have been using both answers with some success.
Morfinismo: I've successfully used the code you directed me to on existing records but cannot seem to get it to work for newly created records.
For example:
widget.datasource.createItem(); // This creates a new record
var managerRecord = app.datasources.Manager.item; // This sets the Manager of the currently selected parent record as a variable successfully.
var teamRecord = app.datasources.Teams.item; // This attempts to set the Manager of the currently selected record as a variable. However, the record that was created in line 1 is not selected. Therefore, App Maker does not seem to know which record this line of code relates to and returns the error Cannot set property ‘Manager’ of null.
// Assign the manager to the team.
teamRecord.Manager = managerRecord; // This successfully assigns the manager but only in cases where the previous line of code was successful (i.e. existing records and not newly created ones).
Do you have any suggestions or comments on how to apply this code to records that are created by the initial line of code in line 1?
I have found the easiest way to create related items for situations such as yours is to actually import a form with the datasource set to Parent: Child (relation) or Parent: Child (relation) (create). So in your case the datasource would need to be set to Order: Order_Items (relation).
You can get this accomplished in two different ways using the form widget wizard:
Option 1:
If your page datasource is set to Order_Items, drag your form on your page.
In the datasource selection section, your datasource in the form widget should default to `Inherited: Order_Items'. Click the 'Advanced' button in the bottom left corner, then from the datasources category find Order as your datasource, then select relations in the next field, and then Order_Items in the next field, choose 'Insert only' or 'Edit' form and then the appropriate fields you want in the form.
Now every item that gets created in that form will automatically be a child record of the currently selected record in your Order datasource.
Option 2:
If your page datasource is set to Order, drag your form on your page.
In the datasource selection section, your datasource in the form widget should default to Inherited: Order. Scroll down in your datasource selection section until you find Order: Order_Items (relation), then choose 'Insert only' or 'Edit' form and then the appropriate fields you want in the form.
Now every item that gets created in that form will automatically be a child record of the currently selected record in your Order datasource.
In your Order model, make sure that the security setting is set appropriately that a user is allowed to create relations of Order_Items in Order. That is the simplest approach in my opinion since you don't have to hard code the parent into your form or client/server scripts. It is automatically based on the currently selected parent, and is essentially doing the same thing that #Morfinismo explained in the client script section.
The comment I placed under your question included a link to the official documentation that explains what you need. Anyways, your question is not clear enough to determine whether you are creating the records via client script or server script, hence this is a very general answer.
To manage relations via client script:
var managerRecord = app.datasources.Manager.item;
var teamRecord = app.datasources.Teams.item;
// Assign the manager to the team.
teamRecord.Manager = managerRecord;
// Changes are saved automatically if the datasource in auto-save mode
// Add a team member to a Manager's team.
// Note: Retrieve Members on the client before proceeding, such as by using prefetch option in datasource - datasources Team -> Members)
var engineerRecord = app.datasources.TeamMember.item;
teamRecord.Members.push(engineerRecord);
To manage relations via server script:
// Get the record for the Team to modify.
var teamRecord = app.models.Teams.getRecord("team1");
// Assign a manager to the Team.
var managerRecord = app.models.EmployeeDB.getRecord("manager1");
teamRecord.Manager = managerRecord;
// Note: The new association is not saved yet
// Assign a team member to the Team.
var engineerRecord = app.models.EmployeeDB.getRecord("engineer1");
teamRecord.Members.push(engineerRecord);
// Save both changes to the database.
app.saveRecords([teamRecord]);
The above information is taken directly from the official documentation, which like I said, I referred to in the comment I placed under your question.

How to control access to a InfoPath Form Button that is controlled by a SharePoint Security Group

I was wondering if there is away to control a InfoPath Form Button enable it if you are in the Security Group and disable it if you are not in the SharePoint Security Group.
Client does not want to use the list method.
Well it isn't possible. However there is a workaround I sometimes use:
You create a list and add only one item. Give unique permissions on that particular item for only the Group.
Then in InfoPath create a Data Connection on that list and check with rules if the ID is present of the data result (or check on some value if you want). If user is in the group then it will get that one record. If not the user it will result in no records.

What is the syntax to add a column to the Custom Form list that shows where in WF it is used?

Super simple.
When viewing the list of Custom Forms in Setup, I want to add a column that shows where those Custom Forms are in use (or null if used nowhere).
This is similar in principle to viewing the list of fields, which has a list of forms on which those fields are used.
What is the syntax I can use to add the appropriate column(s) to the view?
As far as I know, there is no linkage in the backend that connects categories (custom forms) to their host objects. This is probably because the list could be massive and the query would take quite a while to execute as it would have to traverse every object in Workfront or each form would store every parent object ID.
Unfortunately, you can't even search for objects by associated category IDs, so if you wanted to build this yourself you would need to query each object and search its categories to see if your custom form appeared.

When passing an ObservableCollection using MVVM Light's messaging, is a copy passed or is a reference passed?

We're working on a new WPF app, using MVVM Light. We've got a customized ObservableCollection which starts as being bound to a datagrid. According to the project's specification we have to start on a form showing the datagrid and then when a user selects a row we show the user a detail view in another form. At this point we're getting the selected row and assigning that to an object which we assign to a MVVM Light message so that the detail view will be able to display the record's details.
Now that we're getting into this we've encountered a complication. The specs require that the detail view be able to navigate through the collection, even though at this point it doesn't have the collection. We had through we could accomplish this through an interface we defined that we called IRecordService, implementing it for each type of record we work with. However the problem is that the record has no idea if its the first record in the collection, the last one, etc. And that's necessary because of buttons on the detail form where people can navigate through the collection. We've been trying to do this with, for example CustomerRecordService, but so far that hasn't worked out. Perhaps it will if we keep at it.
But I've been wondering, what if instead of creating an object that has the selected record in it which gets passed into a message, we instead pass the whole collection and the key to the selected record into the message which then is caught by the detail viewmodel? My co-workers primary concern is how is the ObservableCollection passed, under these circumstances? Is a copy of the ObservableCollection passed or a reference to theObservableCollection that's in the listing viewmodel? I would think its a reference, but wanted to ask to make sure I'm right, or not.
It has to be just a reference. Otherwise messenger would have to know how to clone every single object. But you can easilly check it. After you get an object in your details viewmodel, change it. Add something, remove something and change some parameter of some objects in the collection. Then check if it has been changed in the main form with the grid.

CRM 2011 - Using contact data on Case form

I've installed CRM 2011 to see if I can tailor it to our business. We do repairs, I want to be able to book in a contact (client) and then a case and have the clients number and address print on the case form. All I can find are fields relevant to the case and not client, any idea on how I can select them?
To get fields from the contact onto the case form you could -
Create redundant fields on the case form for the fields that you want to port over from the contact, and then edit the mappings of the relationship from Contact to Case to map those fields to the case.
Create a web application that loads contact data and then add it to an iframe on the case form. Make it so that the web application accepts the case id in the query string of the URL so that it can look up the related contact and load its details within the web app.
Add JScript (or HTML resource in 2011) to the case form to load the contact values on the fly. You will have to use SOAP XML (or REST endpoints in 2011) messages to pull the data from the CRM service and then can inject it into the CRM case form's DOM.
Option 1 is the quickest solution but will not be realtime (only comes over when the case is first created and must be related to the contact on creation. Option 1 also adds some database redundancy.
Option 2 is the most supported realtime solution, but also requires the most work.
Option 3 is easier than option 2, but any DOM injection will likely not be supported for future releases.
EDIT
To use the mapping option, go to Settings > Customization > "Customize the System". Expand the Case item in the left hand navigation. Then click on N:1 relationships and open the relationship "incident_customer_contacts". This relationship connects the contact to its cases.
On the relationship window click on "Mappings" in the left hand navigation. This controls what fields are mapped from the case when it is created.
Click new and select the contact field from the left that you want to map to the case on the right. Repeat this for each field that you want mapped. Note that the fields need to be the same types, and if they are option sets, they will have to have the same underlying integer values for each of their options.
Now when you create a new case from a contact (or set the contact during the create), the fields should map onto the case.
Seeing as how Craig mentioned he's using CRM 2011, I felt I'd clarify that for Option 3 of Cole's suggestion, you can also use SOAP Xml against the Organization Service, or just use the REST endpoint and both will be supported. So long as you utilize CRM's Xrm.Page object to display the data on the form and don't do any other DOM manipulation, you should be fully supported.
Another Option, "Option 2b" we'll call it would be to add fields to the form for the data you want to be loaded, then add a plugin registered to the Retrieve of the case entity that would populate those fields on the fly for you. No redundancy other than the fields on the form at that point.
I would personally recommend Option 2b if possible because there will not be any lag in loading the data onto the form, and it provides for minimal data redundancy, minimal service calls, and the least amount of additional customizations.
My option is a lot easy one. All we are doing is using Dialog to create cases and in the dialog fields you can get contact detail dynamically. At the end of the form when you create new case, use this dynamic values to submit in Case form.
We get times when customer tell us that the phone number is changed since last time and this method gives you option to change customer's details on the fly and submit both in Contact Entity and Case entity at the same time.

Resources