LightSwitch HTML Client save calculated results to new field - vb.net

I'm using Visual Studio 2013 LightSwitch to attempt to build an HTML application. After trying for several hours to get a "computed" column/field to show up in the HTML client, I realized it's not possible. I thought about building a trigger to fire on the table, but that won't get pushed when I publish the application. So, without using a RIA client, what's the best way to calculate using two or more datasource fields and store in another? It can be triggered when the user clicks the save button or even when the fields contain data that can be computed.
For example, Table Users (before):
First_Name (string) Last_Name (string) Stored_Full_Name (string)
John User NULL
Jane Doe NULL
When the user clicks save, or when first_name and last_name are not null, "Last_Name, First_Name" is stored as a single column in the Stored_Full_Name column in the same table.
For example, Table Users (after):
First_Name (string) Last_Name (string) Stored_Full_Name (string)
John User User, John
Jane Doe Doe, Jane
I'm assuming the same technique could be used to calculate costs or other items?
Any example code would be greatly appreciated.

For simple computed properties, you can always create functions on the Users prototype.
It's explained in this blog post: http://lobfactory.wordpress.com/2013/05/03/computed-fields-in-the-html5-client/

This is pretty easy. Create a string-typed screen variable called "FullName" with display text of "Full Name". Edit the Screen's "create" method and assign the value you want to the variable in JavaScript. - in the example above you'd want something like the following:
screen.FullName = screen.Last_Name.value + ", " + screen.First_name.value;
Then drag the variable from the data tab on the left onto your screen into your Users table.
You might need to update the computed value as part of your Save pipeline, but the create() method should fire any time the screen is redrawn. If you want to save this into a nullable column within your Users table you can do so by simply assigning the field value to the new value, but I'm not sure why you'd bother as this breaks your table's normalization. In the function where you pre-process saved changes on the client-side, add the following code to make this so anyway:
screen.FullNameTableField = screen.FullName.value;
I use a very similar technique for creating in-row "Edit" and "Delete" record-level table entries.
HTH

Related

How to save the ids from one form in one page to another intermediate table

I have users table where role is a field in it which can be student, patent, teacher and admin.
I have to insert data in student form in one page, it can be done with users whose role is set to student.
Now in another page there is a form for filling out additional data such as father and mother details.
I used two objects so that I can store this father and mother information.
Now when I click on next button these id's (student_id, father_id, mother_id) should be stored in student_parents table whose fields are student_id, parent_id, relation.
In nutshell there is a student form when I fill this and click on next button I have to enter parent form after filling this form both father_id, mother_id, student_id which comes from Users should be stored in student_patents table.I am new to this.By the way I am using Graphql and Vue.js.
If you could provide us your code sample you would get more accurate answers.
One way is to use APis to POST data to server and then GET them back in another page.
The other solution is to store your data in LocalStorage and then use the stored data in another place.
if you want to save data as objects here is the way :
localStorage stores key-value pairs. So to store a entire javascript object we need to serialize it first (with JSON.stringify, for example):
localStorage.setItem('user', JSON.stringify(user));
Then to retrieve it from the store and convert to an object again:
var user = JSON.parse(localStorage.getItem('user'));
If we need to delete all entries of the store we can simply do:

How to create a dynamic LOV at runtime

How to create a dynamic attribute in lov at runtime?
Suppose I have a employee lov, where only two attributes are currently present like employee id and employee name.
It user want to add a few more column at run time like employee age and employee salary.
Without changing the LOV logic. The user has one master table where IT user can handle how many attribute should be displayed to business user. They can add a new parameter in table which can be displayed.
Can anybody suggest me some approach to handle this type of scenario?
If I got you right, I'd use backingBean with method that returns List, that implemented as ArrayList<SelectItem>. Then populate from any source(like VO, or whatever mixed) label and value according to your current user request.

Set value dynamic action not working in apex

I have a problem creating sql dynamic action in oracle apex v4.2. I have two fields, Department number and department name. Department number is a text field with autocomplete. The department name is a display field. On changing the department number, the department name should be displayed by an sql query.
I created a set value dynamic action on department number, giving the correct values in page item to submit and the correct sql query referencing P3_DEPARTMENT_NO.
When i run the page, after select a department number, the department name is not coming up automatically.
Could you please suggest on what i might be missing.
Thanks in advance.
You can try use this way:
First step: In the Shared Components -> Application Processes: create a process myProcess an put your sql dynamic in.
Second step: Create a javascript function myFunction to call the process myProcess.
Third step: Use onChange event to call your javascript function myFunction.
Also you can find a lot of exemples on Denes Kubicek app: https://apex.oracle.com/pls/otn/f?p=31517:101:116042570427567.
Best regards,
iulian
The exact behaviour of autocomplete lists is probably browser dependent, but generally speaking, don't rely on the "Change" event, as it won't necessarily fire when you select from the list.
You'll need to experiment to get the behaviour you want in your particular situation, but as a starting point you might want to try replacing the "Change" event type on your dynamic action with "Lose focus". That way the dynamic action should always be triggered when you tab or click away from P3_DEPARTMENT_NO.
In similar situations in the past, I've used "Key release" instead of "Lose focus", and I've created a second dynamic action which does the same thing, but triggered by "Get focus". That combination ensures that the display field stays synchronised with the user's selection, whether a value is keyed in or selected from the autocomplete list. Whether or not you go this route depends on how happy you are about the database being hit with your department name query every time a user interacts with P3_DEPARTMENT_NO in any way.

MS Access 2007 - Select multiple records and assign a value into a field

I am using a Multiple Items Form to list CASES (records) where there is no TECHNICIAN assigned (Maybe I should use a Datasheet to list the records?).
I would like the user to select a TECHNICIAN from a dropdown field that gets its values from an Employee Table (I can do this). Then I would like the user to select multiple CASES (records) in order to assign that one TECHNICIAN to the Technician field in all of the selected CASES.
Basically, I'm trying to keep the user from having to assign a technician from within each and every incoming case request. I want them to "batch" assign a tech to multiple cases.
Can someone point me in the right direction?
Ok so I did some more research. This may not be the best answer but it works for now.
I created a Multiple Item Form.
I added an unbound dropbox that lists Employees from the table
I added a button on the detail section (for each record) with the follow line of code:
Me.Technician = Me.Choose_Technician
Now the user can pick a technician from the dropdown and then click the button to assign that technician to the record/casefile.
This is a simple solution if you only have a couple of records/casefiles to assign. If the amount of incoming casefiles increases there will have to be a way to select multiple records using the shift key. I'll keep researching this.

what editable control should i use to display my spreadsheet in a vb.net application?

I have a spreadsheet in excel with three headers:
Project Name
The name of a project i'm working on.
Requested Role
The job title/profession of the project employee. (example: mechanic, manager, engineer)
Name
The name of the employee.
When i click on the Person's name i want another page or tab (specific to this person) to appear showing details about them such as their name, job title, how long they worked, what project they are doing... etc. (similar to a Facebook profile)
When i click on the project name i want another page or tab (specific to this project) to appear showing details about it such as the requirements, the deadline, who is currently working on it... etc.
Furthermore, i would like to set up two levels of access:
Managers:
People who can add new information but not change or delete existing information
(write-only permissions)
Administrators:
People who can have full access to all information.
All highest level of access.
I don't know how i would go about displaying and/or organizing so much information in a vb.net application. if anyone could provide some suggestions as to some possible layouts of the GUI it would be greatly appreciated!
Additional Details:
For the specific pages i was thinking of using the tab control but i want it so that i can search through the list of projects or names, select one, and then it brings up the page about it.
The levels of access is the least of my worries... although it is still a worry.
You don't want to store that information in an excel spreadsheet, a database is much, much better. For what you've described here I'm going to assume that you have Projects and Employees, and that multiple Employees can work on a project. You'll need a few tables then:
Project
ProjectSeq 'Int - unique sequence for this project record
Name 'String - name of project
Descr 'String - description of project
... 'Various - other fields as needed
Employee
EmployeeSeq 'Int - unique sequence for this employee record
Name 'String - Name of employee
Title 'String - Job title of this employee
IsManager 'Boolean - Is this employee a manager?
IsAdmin 'Boolean - Is this employee an administrator?
... 'Various - other fields as needed
ProjEmpl
ProjEmplSeq 'Int - unique sequence for this project-employee record
ProjSeq 'Int - link to project record
EmployeeSeq 'Int - link to employee record
... 'Various - other fields that apply to this project-employee combination
Once you have your tables all set up and populated with data, you'll want to read the data and transfer it to your .NET application. There are a few ways of doing this, you'll have to decide which works best for your needs. I'm a big fan of DataSets, they always work nicely.
To fill the grid, you'll need to use a sql statement that fills a datatable from the three tables (I'm using notepad as my IDE, so this may not be exact):
SELECT pe.*, p.Name as ProjName, e.Name as EmplName, e.Title
FROM ProjEmpl pe, Project p, Employee e
WHERE p.ProjectSeq = pe.ProjectSeq AND
e.EmployeeSeq = pe.EmployeeSeq
To display the data to the end user, you would use a DataGridView control. Set the datagrid.DataSource to use the datatable you just populated and the data should show up.
To display the related Employee & Project information, I'd use a tab control underneath the datagrid. One tab for Project, and one tab for Employee. Use individual controls for each field in the table. When the user changes rows in the datagrid, load the related Project and Employee information for that row into two datatables and populate the controls from that.
Lastly, to set permissions on the program you'll need to have the employee log onto the application. Once they've logged on you can look them up in the Employee table, find out if they are a manager or an administrator, and set the permissions accordingly.