Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Click on Add to save it and view the Table.

 

 

Linking Data Between Tables

So creating tables isn't that thrilling but what if we could start linking data between them, this is much more useful when wanting to add properties to the Nodes table for example, but lets add a look up to our SampleTable.

Lets add a Business Service to our Sample table. We will need to edit the Table Configuration and add some additional code to use the NMIS API.

Code Block
use NMIS;
use Auth;
my $C = loadConfTable();
# variables used for the security mods
my $AU = Auth->new(conf => $C); # Auth::new will reap init values from NMIS::config
# Calling program needs to do auth, then set the ENVIRONMENT before this is called.
$AU->SetUser($ENV{'NMIS_USER'});

%hash = (
  SampleTable => [
    { Email => { header => 'Email Address', display => 'key,header,text', value => [""] }},
    { Name => { header => 'Name', display => 'header,text', value => [""] }},
    { Age => { header => 'Age', display => 'header,text', value => [""] }},
    { Married => { header => 'Married', display => 'popup',value => ["true", "false"] }}, 
    { businessService => { header => 'Business Service',display => 'header,pop',value => [ sort keys %{loadGenericTable('BusinessServices')} ] }},
  ]
);

These lines setup the NMIS API

Code Block
use NMIS;
use Auth;
my $C = loadConfTable();
# variables used for the security mods
my $AU = Auth->new(conf => $C); # Auth::new will reap init values from NMIS::config
# Calling program needs to do auth, then set the ENVIRONMENT before this is called.
$AU->SetUser($ENV{'NMIS_USER'});

Then this line added to the %hash section gives up the lookup value.

Code Block
 { businessService => { header => 'Business Service',display => 'header,pop',value => [ sort keys %{loadGenericTable('BusinessServices')} ] }},

Refresh our widget and you will see the new empty value.

Image Added

Edit that record and you can see a select box made up of the linked data.

Image Added

Yes it really is that easy.

Feedback

We would love you get your feedback, please let us know if you had any problems or would like more information at contact@opmantek.com

 The first step to creating a new table is to define the Table Configuration