Link directly to detail view with field data?

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
BestMacs
Posts: 8
Joined: 2013-07-12 13:21

Link directly to detail view with field data?

Post by BestMacs » 2015-03-26 18:15

Hello, again!

I have detail view set to display in a separate page from table view.

If I pull up hosts_view.php with "?SelectedID=123" then I get the detail view on the "123" record.

But each of my records have their own unique identifier (a hardware serial number) that I will know so I'd like to do something like this:

?SelectedMyField=ABCDEF

and get the detail view for the record that has MyField set to ABCDEF

Possible?

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: Link directly to detail view with field data?

Post by shasta59 » 2015-04-04 22:07

I assume you are using 5.31

One way to do it would be to change the ID field to your unique identifier. You could do this manually but that is not really a good solution.

Here is how I would do it.

After you save the new record write some code to change the id field to what you want.

Steps:

1. Locate code which is run when Save button is clicked
2. Put in a variable the value you wish to change the id field to. '$newidvalue' as an example.
2. Add subroutine to change the id to the value from one of your fields in the new record. In this case your unique identifier.

UPDATE Users SET id =$newidvalue, where field_name = 'ABCDEF';

field_name is the field which contains your unique identifier. You may also have to change the field type for the 'id' field if your unique identifier contains other than numbers . One caution! This may or may not work for you. If you do try this work on a copy of the database only! (Do not modify your original code - work on a copy only). The 'id' field is usually an index field also so be aware of this.

You will have two fields with the same value now. The id field and your original unique identifier value. But this is a big don't care really.

Again, I am not sure if this will work without testing it in many circumstances. But, if you work on a copy of the code and a copy of the database if it does not work then no harm no foul.I cannot see why it should not as I have done something very similar.

I do this sort of thing for ownership of records in one app. A supervisor does the evaluation but when saving it changes the ownership of the record to the person who was evaluated so they can view it. Same kind of idea. It gets the user name and group of the person being evaluated and then after the save button is clicked it changes the ownership so the person who is evaluated can look at the record.

If you try this and it works let us know. It should be fairly simple.

You can put the code into the yourtablename_dml.php file or you could do it as a hook. Put the code in the after_insert section.

Not sure if any of this makes sense but...

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

Post Reply