Make a record in one Entity Inactive when a value is changed in another Entity of the same record in crm 2011 on-premise - workflow

I have two entities, Bookings and Discharge.
When a record is created in Bookings, it automatically creates a record in Discharge. Discharge
has an additional field that is a drop down with four options.
I want a functionality where when any one of the values in drop down is chosen, the similar record in Bookings
should shift from "Active" view to a default view which I have created by the name of "Processed" in Bookings.
What I have in mind is to create a hidden field in Bookings that is populated when I choose one of the options from Discharge drop down and based on that field the record should shift the view in Bookings. But how do I populate the hidden field? Workflow is not giving me that option or maybe I am doing something wrong.
Help?
So I have created a 1:N relationship between Booking and Discharge. The field is updated in Booking based on the field in Discharge and I choose the particular record in Booking from the look up field in Discharge. But I want to get rid of this second step. I don't want to choose the record in Booking entity but directly update it from Discharge. There are some fields and their values common in both forms, can I create a relationship based on that?

Regarding the first part of your question
"What I have in mind is to create a hidden field in Bookings that is populated when I choose one of the options from Discharge drop down and based on that field the record should shift the view in Bookings. But how do I populate the hidden field?"
If the field is not on a form you can't set its value hence the following:
I don't believe you can set a hidden field using a workflow. However there is a 'visibility' option on the form designer.
I suggest you add your "hidden" field to the form. Then double click on it and toggle the "Visible by default" checkbox. This will hide the field from the user.
You can then set the value of this field using a workflow.
Regarding part two of your question
I don't want to choose the record in Booking entity but directly update it from Discharge. There are some fields and their values common in both forms, can I create a relationship based on that
You have a 1:N relationship however you want to set the related Booking Dynamically is this correct? You cannot select a Booking in the lookup field based on criteria from a workflow. You would need to use a plugin.
If the Discharge has a related Booking (the Booking lookup on Discharge is already set) then you can use a workflow to either:
1) Set a field value (Using 'Update Record' in the Workflow steps) in the parent Booking
2) set to Inactive (Using 'Change Status' in the Workflow steps) in the parent Booking

Related

Inputting data from a form into a junction table Microsoft Access

In access I want a single form which can input data into a junction table. The relationships are as follows.
One table has plant names and basic information on the plants, another table has soil moisture content and another table has county names in which certain plants may be found. One plant may be found in many counties and many plants may be found in one county. Same goes for moisture. Thus, this database needs to many to many relationships. How can I make a form which takes a plantID as well as the counties and moistures of that plant and forms an entry in the junction table? Am I approaching this problem in an appropriate way?
Assuming that you only need to add records to the junction table from this form, build a form bound to the junction table.
If you use the wizard, your new form should list each field as a textbox.
For each field that is a foreign key, change the textbox to a combobox. Use the row source property to pull the information from that field's devoted table where the PK resides.
So for example, MoistureID will become a combobox whose row source would be:
SELECT MoistureID, Moisture
FROM Moisture;
The ID field will then be the output of the combobox but will display the Moisture field when the list opens. You can hide the ID field from the user by changing the "column width" property to 0";1" but make sure the "column count" property = 2.
Then you can change the form's data entry property to "yes" to hide the existing junction records from the view of the form.
In form view, choose your plant ID and other selections and once you tab past the end of the form's tab order, your junction record should append to the junction table and the form's controls should clear.
If you need to add records to other tables from this form then you will need to build an unbound form and handle the appends using macros or VBA.

Triggering an event on one subform based on a change in another subform

I have a main form with two subforms. The first subform (subformList) displays a list of employees and a second subform(subformDetails) provides the details for that employee.
I use the practice of having a control field in the main form hving the value of the chosen employee in the subformList subform and having the master/child link of the employee details subform based on this value.
Up to this pointe everything works great. I choose an employee is one subform and the other subform displays the new details.
The problem I have is that I need a of one of the fields in the subformDetails form to execute after the details change from clicking another employee in the subformList subform. If I code a requery of the control field in question in the subformDetails field, it simply requeries with the old value (the control is a listbox with a query as a record source. As expected I can click on the same employee in the subformList subform a second time and the correct details are displayed in the control field in question.
So the question that I have is: Is there a way to rigger an event AFTER the forms have updated each other.
Note that I thought I could simply have an event one of the subformDetails controls so when the other subform forms forces a change then there would be a trigger to perform the requery I need. However it seems events are based on direct changes and not coded changes from other forms.
Whilst writing the question I thought that maybe what I should do is manually force the subformDetails to be refreshed before executing the requery for the control (listbox) and this worked.
So just to summarise
When I click on an employee in the employee list subform I have an onclick event that would run a requery on a listbox in the employee details subform. Unfortunately this requery uses a control box in the employee details subform that does not get updated until sometime after the onclick event (the relationship between the two forms is established with the link master/child and a hidden field in the main form.
The fix is to requery the employee details subform before I run the requery for the listbox. This is because click on the employee in the list changes to record source row and refresh the form makes sure the control has that new value before the listbox requery is executed.
I still don't know what triggers the form change between the two subforms in the first place. It must be performed implicitely.

Symfony2: Collection of dropdown select lists for a many-to-many relationship

The objective:
Having a many-to-many relation be displayed as a dynamic list of select inputs(single choice dropdown list)
User arrives on page with a single select field (multiple = false) populated with persisted entities and add/remove buttons. By clicking the add button, a new select field with the same options appears below the first, which adds a new entry in the M2M relation. By clicking remove the field disappears and the entry should be removed.
The model:
Two entities: User & Manager. A User has exactly one "special" Manager and unlimited normal Managers.
Managers manage unlimited users.To model this I have created two relationships for which the user is the "owner" (not sure how to translate this)
ManyToOne specialManager
ManyToMany normalManagers
I haven't created a many to many relationship with attribute "special" because the requirement is exactly one special manager and I wasn't sure if Symfony/Doctrine would cause problems down the line.
What I have:
I can display a multiple select field with the existing entities using Entity field type, as per the documentation. Functionally this is what I need, visually it is not.
I can also use the Collection field type to display a single text field, and add or remove more with JS, as per the documentation. Visually this is what I need, but The text fields (entity attribute) need to be replaced by choice field.
The question:
Before I continue digging, is there a simple way to achieve this list of select tags?
For anyone else who may eventually need a dynamic list of select fields:
I initially solved this issue by detaching the field(s) in event listeners, and handling the display/submission manually in the controller.
However I wasn't satisfied with this clunky solution and when I encountered the same need I used a second solution: creating an intermediary entity xxxChoice (in this case ManagerChoice) which is Mto1 inversed related to User and Mto1 related to Manager. Then by creating a ManagerChoiceType form with "Manager" entity field type I was able to easily display my collection of dropdown select lists.

Create record in related table *only* if not previously existing there

I have a Filemaker database with a Members table, an Events table, and a join table called Attendance which should list which members attended which events. Attendance has the setting "allow creation of new records" ticked for Members (doesn't need it for Events).
Data arrives in an Excel spreadsheet for importing to Attendance. But then I want to see if there are people attending who aren't in our records already... sort of like this:
look at each of the newly added records in the attendance table
see if the members mentioned there exist in the member table
if so, do nothing
else create a new record in the member table for them, using data from the attendance table.
If I'm understanding it correctly, Steps 3 and 4 should look something like this:
Set Variable [ $fname; Value: Attendance::firstname ]
Go To Layout ["Member" (Firstname)]
New Record/Request
Set Field [Member::Firstname; $fname]
i.e. put the desired info into variables, start a new record in the related table and set the data there to the value of the variables.
But how do I get step 2 happening? I'm guessing some sort of loop will go through the found set of records in Attendance, and grab the relevant identifier. How do I show that to the Member table to see if it's present or not?
"Firstname" might be a bit light to pinpoint a unique member, if you have many members !
I'd presume therefore you would have some sort of unique key for each member.
As from there, just search for the member in the member base, before creating the new record…
Link the two tables with an EQUALS relationship.
Write a script:
// Loop through your attendance records.
// Be sure you're in the correct layout
Go to Layout ["imported list"]
// Attempt to go to the membership record of the person who is attending the event.
Go to Related Record [Show only records from: from table: "membership table"; using layout: "membership table"
// If the person who is attending IS in the membership list, you'll go to that member's record in the "membership table."
// If the person who is attending is NOT in the membership list, you'll get an error. You can use that error in an if statement to execute code to add that member.
If [Get ( LastError ) = "101"]
// insert code to add new member
End if
Since you already have a relationship between Member and Attendance, it means that you can "see" any related Members from the Attendance table across the relationship.
We also know that you only need to evaluate the new attendance records coming in from your spreadsheet.
I also assume that there could possibly be be more than one attendance record per Member in the spreadsheet. This may not be the case, but it's safer to assume it's possible.
I'm also assuming that you are linking the Member table to the Attendance table via the primary key in Members and a foreign key in Attendance, i.e. Member::ID = Attendance::Member ID.
So here's the script process I suggest:
Import the new Attendance record into the Attendance table.
This will give you a found set of only new attendance records
From the Attendance layout, perform a find for related Member records with an omit, i.e.:
# This assumes you're already on the Attendance layout
Enter Find Mode
Set field [Member::ID ; "*"]
Omit record
Constrain Find
This will give you a found set of new Attendance records that do not have matching Member records.
From here you could loop through each of the attendance records and create the Member records as needed.
If you check the Allow creation on the Member side of the Member -< Attendance relationship, you could set the field in the Member table directly from the Attendance layout.
Since the 1 to Many relationship between Member and Attendance goes 1=Member Many=Attendance, you would need to check to be sure you haven't already created a Member record during your loop, i.e. If a new Member had multiple Attendance records you could have already created a Member record during the loop.
Your loop would look like this:
Go to Record [First]
Loop
If [IsEmpty(Member::ID)]
Set Field [Member::First Name] // This first Set Field will create your new Member Record as long as the "Allow Creation" is enabled on the Member side
Set Field [Member::Last Name]
... This would be the rest of your set field steps for Member
End If
Go to Record [Next ; Exit After Last]
End Loop
This way you don't need to navigate away from your Attendance record set. Also, the Primary and Foreign keys for both tables will be created and set automatically through the attributes of the relationship itself.

Ghost change my data after close form

I have a little databes in access. I make a few forms with sub forms and drop list(by query):
Steps of my creating form:
make form from table
delete all not PK or FK text box
create comboBox with store value to text box what I choase
create subForm and set Link Master Fields and child fields
design view:
This is form for table Task task have Fk: Project, peson etc. DropLists are connected tu subform for changing FK like project, person etc. So when I work i select in droplists what i want add to database and work with subForm. When I close this form, the first row in table change FK to last configuration on droplists.. Pleas how can I fix it?
It is quite possible to use a main form for selecting and updating subform records, but in this case it should not be a bound form.
To set up, for want of a better word, a linking form, unbind the main form, that is remove the record source and ensure the dropdowns (comboboxes) do not have control sources. I suggest you rename the dropdowns to cbo, to indicate that they are controls, not fields. The hidden controls should not be needed.
The value of a combobox is the value of the bound column. The Key or FK is the first item in your SELECT statement and the bound column is 1 (one) so the relevant Key or FK is the value of each comboboxe. You can set the link master fields to the names of controls so the Link Master Fields should be cbo_id_projekt;cbo_id_os_udaje;cbo_id_komponent;cbo_id_uloha.
As an aside, I generally avoid underscores, but each to their own.