I have to apply trigger on employee object and get id of project and stored data of Project Assignment - triggers

My Question is
Create a Record of Project with Name = Default and leave all other fields blank.
When an employee is created using the trigger, create a record for project assignment and it should be mapped with the Default record (created above)
I have created a record of project but I don't know how we mapped to project and projext assignment.

Related

How can I delete one field of entity in Moqui?

My question is how can I delete one field of entity in Moqui which that field is deleted from database? Suppose I wrote one entity and define its field but after some time understand its false and I want delete that specific field from database how can I do this in Moqui?
Firstly, you need to delete it in your database.
Then, modify your XML entity definition.
Then, run gradlew load for reloading new database schema.

Web API Entity Framework error - Item with idenity already exists in the metadata collection

I am experimenting with a Web API 2 project in Visual Studio 2012. I used the code first from existing DB option with EF6 to select one table and one view. I then tried to create a controller for the simple table using the profile for Web API 2 OData. The scaffolding of the controller fails telling me that "the item with identity 'Client Last Reveiwed On' already exists in the metadata collection". The problem is not only am I sure that field is unique for this project but that field is part of the view and not the table. Below is the model generated for the simple table (t_Client) that I was trying to create the controller for. As you can see the offending column is not part of the class. I will add below the definition for the column that VS/EF doesn't like which is in the class for the view.
Any ideas why this won't work?
Partial Public Class t_Client
<Key>
<DatabaseGenerated(DatabaseGeneratedOption.None)>
Public Property ClientID As Integer
<Required>
<StringLength(255)>
Public Property ClientName As String
Public Property isActive As Boolean
End Class
Here is the column that is defined in a separate view.
<Column("Client Last Reviewed On", TypeName:="date")>
Public Property Client_Last_Reviewed_On As Date?
I am not sure which of these steps fixed the issue but here are some notes on the topic.
Removing references to the model based on the SQL view eliminated errors.
I went into SQL and updated the view to contain a row number column.
Even with the row number column, EF tagged multiple columns as the key.
I manually edited the model to make the row number column the key.
I also had to update a cast the data type of a few columns in the SQL view to match reality, mainly bigint that was really just integer.
My guess is the fix was the well defined key.

Duplicating MS Access main form record while keeping the parent-child link in the subform

I have a Monthly Reports entry form (data source: MonthlyReports table) with a Project Info subform (data source: Projects table) linked on ProjectID field. ProjectID is a PK in the Projects table and a FK in the MonthlyReports table.
I am trying to use the Duplicate Record button to duplicate the record in the main Monthly Reports form, edit the duplicated record and save it as a new record/monthly report for the same project. I would like to keep the Project Info (or ProjectID link) in the new record after duplicating. When I duplicate the record, it creates a new Monthly Report record with a unique number, but it does not keep the ProjectID foreign key, thus creating an unrelated record without the ProjectID foreign key. How can I modify the macro or add a VB code on click of the Duplicate Record button to keep the Parent-Child field link?
Thank you.
Short answer, If I understand what you're asking, is no.
When you have a relationship between a master and child table, it is a one (Master record) to many (child records) relationship. A child cannot have more than one parent. Even if you haven't defined this relationship in the database, when you link a subform to a master form by a field, that one-to-many is (properly) assumed.
What you would need to do is have the macro, subsequent to creating a new master record, create a new child record then copy the fields of the existing child record to the new record. Finally, you will need to set the value of the new child record field [ProjectID] to be the value of the newly created master record. Now you have the complete duplicate.

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.

Cannot add Currency field to Entity after Importing

A custom entity was created in our DEV environment. It originally had a Currency field, but we decided to remove it and use a Float field for simplicity. After exporting the solution and importing it into QA for the first time, I can no longer add a Currency field to the entity in QA (and the "leftover" transactioncurrencyid column in DEV did not get migrated to QA).
The main problem is that I cannot remove the transactioncurrencyid column and now my Filtered views are different between DEV and QA which causes our SharePoint BCS process that relies on Entity Framework to fail.
Is there any way to completely remove a currency field without recreating the entity?
Plan B: Is there a way to restore a past copy of the entity (prior to removing the currency) from a backup and merge it into our presently broken version?
Plan C: any other ideas (convert EF to use Stored Procs, etc)?
Thanks!
Export the entity from Dev into QA again. CRM will see that a column has been added, and will add it to the entity in QA.
Edit 1
So this is an unmanaged solution in QA? You should be able to just add the field to the entity in QA through the Customize Solution interface.
The MSFT approved solution involved manually removing:
the ExchangeRate column from the Base table (e.g. alter...drop column exchangerate)
the rows referencing the attribute's GUID in the system tables: Attribute, localizedlabel, AttributeIds (e.g. delete from tbl where AttributeId = guid)
altering the entity's View to remove the ExchangeRate column (not the Filtered)
Finding the GUID in Step 2 was done by opening the ExchangeRate field in CRM and pressing F11 to extract the AttributeID from the querystring.