Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Prepopulating a field in a secondary browse screen.

Locked
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Prepopulating a field in a secondary browse screen.

Unread post by danielf »

Very new to nubuilder, and php/java/sql for that matter, so bear with me :shock:

I'm trying to build a relatively simple tool, but in order to make things easier for my end user, I want to deviate slightly from the 'standard' nuBuilder structure. The project I'm working on involves a system for managing 'cases' that each have a number of 'issues' associated with them. The issues in turn have 'actions' and 'outcomes' associated with them. So, I've created three tables in my database. There's one for cases that each have a unique ID and some summary fields. There's an issues table that holds the issues. They each have a 'parentcase' field which links to the case_id for the case they are associated with. Likewise, there's an actions table which links actions to the parent-issue etc, and contains the outcome for that action in the table.

The structure I want for my Nubuilder tool, is to have a browse screen for cases (no problems there). I've added a button to the edit screen for a specific case which takes me to second browse screen which lists the issues for that case. This is done by filtering all issues based on whether the parentcase matches the case-id for the case that was selected in the edit screen. I do not want to use a sub-form for this (as appears to be standard), as the amount of information that needs to be entered is rather large, and a subform doesn't (appear to) give me that flexibility. I will also want to create a third browse screen that will list the actions for an issue. I don't think I can do that from a sub-form. Anyway, the secondary browse screen works as well. What I want to do next, is to allow the user to create new issues for the selected case. This is where I run into difficulty. I want to prepopulate the parentcase for the new issue with the case-id that the issue-list was filtered on (this needs to be automatic so the end-user can't mess it up), and I'm stuck on how to retrieve the case-id. I can retrieve the case-id in the edit screen for that case, but not in the subsequent browse screen for the issues associated with the case. Presumably there is a way to do this (either through a default SQL value, or by passing it through a variable, but I can't figure out how to do this. I will be wanting to repeat this procedure for the actions associated with the issues. So, when I select an issue, I go to a browse screen for actions. Here I want to add new actions and prepopulate the parent-issue. I'm assuming this will work the same way, as the new browse screen will be filtered on the basis of the ID of the parent-issue.

I'm sure this is an extremely basic question, but I'm kinda stuck, so any help would be appreciated.

I hope this makes sense, but in case it doesn't: In terms of an order system, I want to select a customer, and link to a browse screen (rather than subform) that lists all orders for that customer. There, I want to be able to edit orders, as well as add new orders. New orders need to be prepopulated with the customers name/ID that was selected in the browse screen.

Cheers,

Dan
admin
Site Admin
Posts: 2778
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5

Re: Prepopulating a field in a secondary browse screen.

Unread post by admin »

Dan,

I had to read it a couple of times but I think I understand.

Pretty simple concept really but I think the way you want to navigate through your application is a bit hard.

Firstly if I've got it right, this is your table structure..
case > issue > action

The problem is that to create an action you want to firstly pick the case then the issue and then add an action.

eg.
forum.png
forum.png (22.77 KiB) Viewed 6364 times
When most of the time will be spent actually adding actions.

Actions should be added directly from the index page (1) and the issue its for, chosen from a lookup.(4)
forum2.png
forum2.png (18.9 KiB) Viewed 6364 times

It means rethinking your plan, but when you understand the power of a browse screen and lookups it should all make sense.

(browse screen 4 should be a joined query of both case and issue, making it easy to find by filtering)
(browse screen 2 should be a joined query of both case and issue and actions, making it easy to find by filtering)

And it won't confuse your users as much.

(I know its not the answer you wanted - I don't have an easy one - sorry)

Steven
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Prepopulating a field in a secondary browse screen.

Unread post by danielf »

Hi Steven,

Thanks. I think you understood correctly. It's like a CD collection: Artists --> Albums --> Songs. Users would be able to browse Artists, then Albums, then Songs, and add where necessary. I understand how a lookup would work, but it really isn't how I want to organise things. My end users will have limited experience in using computers, so I really want to make things as intuitive as possible and I don't think a lookup would be very intuitive. I think a subform would work better, but that doesn't (as far as I can tell) give me the flexibility to click through to a secondary subform, which would hold actions and outcomes.

Is there no way to stick the case/issue ID in a variable which I could then use to populate a field in a secondary browse screen? The idea would be to first have a browse screen for case, then select one, and stick the case ID in a variable. Next, I'd launch a secondary browse screen filtering for case * issue, and use the variable to populate the parentcase slot when the user wants to add an issue. This would be repeated one level down when selecting actions for cases, but the same logic would apply.

Cheers,

Dan.
FBC-Tim
Posts: 25
Joined: Thu Jun 23, 2011 6:08 am

Re: Prepopulating a field in a secondary browse screen.

Unread post by FBC-Tim »

To edit an entry already shown in the subform I have used this:
In the subform you can use the "On Double Click" for all subform objects with some code like this ...

Code: Select all

openForm('14e27b1abea190',nuGetRowId());
When the user double clicks an object in the subform row this code will launch an edit window with the record that was shown in the subform. I made sure this edit form only has the 'Close Button' enabeled in the Action Buttons" because I did not want the user adding another record at this point.
See more details from Steven on how to do this here http://forums.nubuilder.cloud/viewtopic.p ... tton#p6550

To add a new record to the subform data I have used this:
In my case I am adding NOTES to a CLEANING JOB.
At the top of the edit form (that has the subform showing the notes) I have added an "Extra Action Button" titled 'Add New Note'. In the display condition I have "SELECT IF('#recordID#' = -1,0,1);" so that the button will not show for a new record, only an existing record that has a primary key assigned already. In the "Javascript to run" I have the code "newCleanNote();", this calls a function I have defined in the Javascript tab.
In the "Javascript" tab I have this code:

Code: Select all

function newCleanNote() {
  nuCreateCookie('sc_owner_id_for_note', document.getElementById('recordID').value, 1);
  nuCreateCookie('sc_owner_type_for_note', '1', 1);
  openForm('14e27b1abea190','-1');
}
This saves the data I need to transfer into the new edit form in local cookies and opens the edit form with a new record. The two items of data I am using here are, 1. The key of the current cleaning job record and 2. the type of note I want to save, in my case 1 = note relating to cleaning record.

So now my NOTE edit form will open. On this form I have two hidden objects ready to hold the data from my cookies. These have the correct fields set, so when the user saves the NOTE when they have finished editing the data from the cookies will be saved in the appropriate fields for the new NOTE record.
In the "Javascript" tab of my NOTE form I have this code:

Code: Select all

$(document).ready(function() {
  if ($('#recordID').val() == -1) {
    sc_OwnerID = nuReadCookie('sc_owner_id_for_note');
    sc_OwnerType = nuReadCookie('sc_owner_type_for_note');

    nuEraseCookie('sc_owner_id_for_note');
    nuEraseCookie('sc_owner_type_for_note');

    $('#n_owner_id').val(sc_OwnerID);
    $('#n_owner_type').val(sc_OwnerType);
  }
});
This jquery code runs automatically when the browser has fully loaded my edit screen. It quits out if we are not creating a new record so it will not interfere when this edit form is used to edit an existing NOTE. It then reads data from the two cookies into variables, deletes the cookies and pokes the data into the appropriate hidden objects.

I know this is not exactly what you are looking for but it may help.
On your CASE edit screen you could have an "Extra Action Button" called 'Add an Issue to this Case'

Please note: I am not from nuBuilder I have just been using it for a while and discovered these solutions. Hopefully they may be useful to you ;)
(admin, please feel free to correct me if I have said the wrong thing)
admin
Site Admin
Posts: 2778
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5

Re: Prepopulating a field in a secondary browse screen.

Unread post by admin »

FBC-Timm,

Thanks for your help

theres nothing to correct, if it works for you.

Steven
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Prepopulating a field in a secondary browse screen.

Unread post by danielf »

Thanks for your help guys. Much appreciated. ;)

FBC-Timm: Thanks, this sounds like it would do the job. I like the idea of clearing the cookie so as not to interfere with existing notes. That's the one thing I was afraid of with using a variable to hold the record-id. With all the tabs/windows that tend to be opened, I think there might be an issue with users losing track of where they are, and this sounds like it would avoid those problems.

Thanks!

Dan.
admin
Site Admin
Posts: 2778
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5

Re: Prepopulating a field in a secondary browse screen.

Unread post by admin »

.
Locked