How to create a new Column in CalEvent table corresponding to the newly created field in "Add Event" page of Calendar portlet? - liferay-6

<aui:select name="Event for">
<%
for (User usr : UserLocalServiceUtil.getRoleUsers(10163)) {
%>
<aui:option label="<%=usr.getFullName()%>" />
<%
}
%>
</aui:select>
I have created a new field in Add Event page of Calendar portlet.
I want to create a new column in CalEvent table corresponding to the newly created field. Like wise i should get the value of that field by creating CalEvent instance.... So while clicking Save in Add Event page, the value of newly created field also should be saved in CalEvent table.
The above pasted code is used to create new drop down field "Event for", which will give list of users under a role. This I done by creating Hook.
So, While saving event the value of "Event for" also need to be saved in CalEvent table in "eventFor" column. How can i achive this? How to create new column and how to save it? Please help.....

Your major concern is the database table used for CalEvent. If you can open a database browser, you can find it as the table named "calevent" with primary key "eventId".
Now, if you wanted to add a column in that table, you would need to make extended modifications to the Calendar Portlet's controller and Services, and besides needing so much work, you would lose compatibility with future updates.
So, what i propose, is to make another Portlet and with ServiceBuilder create a table that features the "eventFor" column and has the 'calevent.eventId' as foreign key. If you take the service.jar and copy it in /lib/ext/ you can even include the new service in your hooked add-event.jsp and create the new instances from there.

Related

Take value from field in Form to a new record in other Table

Would really like some guidance on this one. Not as easy as the title might say at first and I'm stuck beyond all and frustrated.
So:
I have a MainForm (With a current ID I would like to stay on!)
I have a Subform (search engine that searches in various linked excel files)
I have 2 tables; one for the Mainform, and one for Items
So on the Mainform, I display the Subform (search).
I do my search and find a specific item in the excel files
I have a command button, that I want to click save the found item in the search field, into my ItemsTable as a new record.
Currently I'm doing this:
Private Sub Command13_Click()
Forms!MainForm.Form.Item1.Value = Me.Searchresult.Value
End Sub
This does actually post my search result into a new field and saves it into the itemsTable.
My problem: I don't need to actually have a field to post to. I just want it to write directly to my table and store it there as a NEW record. (Right now it just overwrites the previous data. Logically because its the same field every time with the same properties).
Can someone PLEASE help me with this one?
Options:
set focus to the subform container then move to New Record row followed by your code, this is not simple, review https://access-programmers.co.uk/forums/showthread.php?t=127337
use SQL INSERT action then requery the subform
CurrentDb.Execute("INSERT INTO Items(Item1) VALUES('" & Me.Searchresult & "'")

Some fields are missing in the fieldexplorer. How to show all fields?

i'm using Crystal Reports with my ERP-System. There have been predefined reports i now want to change.
In the field-explorer are some tables which have been renamed for better readability. But those tables are missing some fields, i want to use. If i connect the whole table again, all fields are there. Is there a way to display all fields in the predefined tables.
I tried to refresh the Database but nothing changes. If i delete the predefined table and then rename the new one to the old one, so i can use all predefinded formulas, all used fields in the report get deleted. I would need to recreate the whole report then.
Thanks for the help
If it is truly the same table and is not showing all the fields then you need to do "Database > Verify Database". That will force CR to refresh the structure of the table (instead of just the data). If this doesn't add the missing fields then the table in the report is actually a different object.
To see what the table/view the report is actually using go to "Database > Set DataSource Location" and look at the properties node for that table. It will show if it is a table/view/SP and what the true object name is.
If you want to replace the existing table with a different table you go to "Database > Set DataSource Location" again. Highlight the existing table in the top window, connect and highlight the replacement table in the bottom window. Then click update. Crystal will replace one table with the other and all of the fields in the report that exist in the new table will be mapped automatically. Note that the new table will keep the alias of the original table. If you are unsure if the table was updated you can look at the properties node in the top window to see the change.

Pop-up form that creates record that links 1:1 to main form

I have a pop-up form that opens using a button on the main form in a MS Access database. The pop-up form creates a new record (in a separate table) that needs to link to the current record in the main form. How do I set this up properly?
The two forms (frmMain, frmWB) are based on 2 separate tables (tblMain and tblWB). The records have a 1:1 relationship (each main record can only have one WB1 record).
The main form (frmMain) has the primary key [ID]
The pop-up from (frmWB) has the primary key [WBID] (autonumber) and [MainID] (number).
Data entry personnel will enter the main info first (this will have to be required to avoid orphans), then click a button that saves the main record and opens the pop-up form to add the detailed info. When done, they click the close button which saves the pop-up record, closes the pop-up, and returns to the main form (which stayed open in behind). Navigation has been disabled in the pop-up and it is set to cycle the current record.
I have tried linking using the primary IDs for the two tables, but that doesn't seem to reliably link the correct ID numbers when adding a new record in the pop-up. I tried using subforms, but had problems if the navigation or 'new record' buttons on the main form were accidentally hit when entering data in the subform - that created records in tblWB that had the wrong ID numbers.
If frmWB is opened modal, so that the current record of frmMain can't be changed while the popup is open, you would have this in the BeforeInsert event procedure of frmWB:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!MainID = Forms!frmMain!ID
End Sub
This automatically assigns the tblMain ID to the newly created tblWB record.
MainID should be an invisible textbox on frmWB, bound to the table field MainID. While debugging you can make it visible, but it should be locked.
If frmWB isn't modal, I would use OpenArgs to pass the ID from frmMain to frmWB. And then use that in Form_BeforeInsert instead of Forms!frmMain!ID
Contrary to Andre's comment, the usual way is to create a relationship between the two tables, enforce referential integrity and use cascading updates.
While this article is specific to Office 2003, the concept is the same for all versions of Access. If you do this, the popup will automatically create a new record linked to the main form's record.

Cannot see records in form bounded to table in Access

I have a form and it's record source is a table. I created the form separately and added the control sources to the different fields in the form and also changed it's record source. I imported values from an excel sheet into the table and when I open the form, I do not see the tabe values being displayed in the form. Any idea what I should do to see the table records in the form?
In form design mode, check the form's DataEntry property. It sounds like yours is set to Yes, which hides existing records and only allows new entries. Change it to No and you will see the existing records.
Another possibility is that a filter is active and no records match that filter.
Use a form wizard to generate a working form based on your table. Then once you can see the data being displayed in the form, customise as needed.

Autonumbering in forms in Access

I have a form in access that saves the data in a database and I want one of the fields to be automatically calculated as the next value in line as the ID so that the user doesnt write the ID. does anyone have any ideas?
Create your table using an Autonumber data type.
If you manually create your tables then this statement
CREATE TABLE TableThatIncrements
(
Id AUTOINCREMENT(1001,1)
)
Alternately you can edit your existing table Id column using:
ALTER TABLE TableThatIncrements
ALTER COLUMN Id AUTOINCREMENT(1001,1)
If you do not, then you can change per the article I mentioned via the GUI interface. See steps in this article: https://superuser.com/questions/288087/how-do-i-set-the-first-value-of-autonumber-in-access
You can run a query in Access by doing the following:
Go to the "Create" tab and click "Query Design"
Just close the window that appears which asks you to select tables, we don't need that.
Go to the "Design" tab and click the button with the arrow until you get a textual input screen. (By default, it says SELECT;).
Delete the default text and paste the above query.
Click "Run".