HowTo reverse the Name property from an ID stored in a SQL Table

  • 13 November 2015
  • 1 reply
  • 2 views

Badge +10

I worked on the BlackPearl tutorial for the Sales Orders....

 

http://help.k2.com/onlinehelp/K2smartforms/UserGuide/4.6.11/default.htm#Resources/Projects/SalesOrdersStudio/SalesOrderStudio.htm

 

In MSSQl Run the following commands to build my Tables....

 

CREATE TABLE Regions

(

RegionID int IDENTITY(1,1) PRIMARY KEY,

RegionName varchar(255) NOT NULL,

RegionVPLoginName varchar(255) NOT NULL

)

 

CREATE TABLE ADSalesPeople

(

ID int IDENTITY(1,1) PRIMARY KEY,

Name varchar(255) NOT NULL,

Email varchar(255) NOT NULL,

Manager varchar(255) NOT NULL

)

 

CREATE TABLE Customers

(

CustomerID int IDENTITY(1,1) PRIMARY KEY,

CustomerName varchar(255) NOT NULL,

ContactPerson varchar(255) NOT NULL,

AccountManager int NOT NULL,

Region int NOT NULL

)

 

CREATE TABLE Products

(

ProductID int IDENTITY(1,1) PRIMARY KEY,

ProductName varchar(255) NOT NULL,

Description text,

Cost decimal(10,2),

ListPrice decimal(10,2),

Discontinued bit NOT NULL

)

 

CREATE TABLE SalesOrderItems

(

SalesOrdItemsID int IDENTITY(1,1) PRIMARY KEY,

HeaderID int NOT NULL,

Product text NOT NULL,

Quantity int NOT NULL,

UnityPrice decimal(10,2),

RowTotal  decimal(10,2)

)

 

CREATE TABLE SalesOrderHeader

(

SalesOrdHeaderID int IDENTITY(1,1) PRIMARY KEY,

Region varchar(255) NOT NULL,

Customer varchar(255) NOT NULL,

Sales Person varchar(255) NOT NULL,

OrderDate date,

ShipDate date,

PONumber varchar(255) NOT NULL,

Tax decimal(10,2),

SubTotal decimal(10,2),

Comments text,

Status varchar(255) NOT NULL

)

 

One thing I noticed is when creating the View From the Simple Sales Orders in List and Form return the ID instead of the Name, because that is what is stored in the Databse

 

17182i744DFA4E54ED004F.jpg

 

This is what the Sales People looks like:

 

15838i1EDDA4BD91B6F475.jpg

 

Shows the ID's of the Account Manager and the Region... instead of display the correct name.

 

I wonder if there is a reverse function within the List to indicate to retrieve the Name of the Foreign Table instead of the ID stored in the Database.

 

THX Dino.


1 reply

Badge +10

After some playing around I think found the answer to my own Post !!!

 

I changed the control in the List back to a dropdown like the original form, and the point it to the main DB Table Reference populating the correct value.

[ Maybe another workaround to link behind the scenes the dependency directly, but this workaround seems to work fine as well ]

 

Go to the main List View , change the control to a dropdown :

 

16215iB9193924AA332E2F.jpg

 

Select the source the RegionID and the Display Region Name

 

15035i4204A39782ABF02A.jpg

 

Hope this helps to somebody !!!, or if you have any suggestions or best practice to this solution feel free to post.

 

THX Dino.

Reply