Database view of 2 tables joined

AbdulRahim Shai
Tera Expert

Hello Developers,

 

Need your expertise in achieving this requirement.

I am trying to join Variables ownership (sc_item_option_mtom) table and Options(sc_item_option) table

Need this view for migrating RITMs variables as per requirement

 

I want the view to have parent item attribute  from (sc_item_option_mtom)  table and  option, value  attribute from (sc_item_option) table
Eg :

AbdulRahimShai_0-1666717280001.png


I am not able see records in view since not sure about where clause to join this table.


AbdulRahimShai_1-1666717365801.png

Requesting your assistance.
Thanks,

AbdulRahim

 

 

 

 

3 ACCEPTED SOLUTIONS

Brad Bowman
Kilo Patron
Kilo Patron

You almost had it.  Try this:

BradBowman_0-1666726403380.png

With the Where clause on the second table

vo_sc_item_option=op_sys_id

Where clauses always follow the format prefix_field_name=prefix_field_name

 

View solution in original post

That's going to be tricky.  To aid in this, right-click the column headers and choose Configure > List Layout to add the Question.Reference and Question.List table (for List Collector variables) to the view.  So now you can at least see the table the sys_id (or list of sys_ids) belongs to.

 

To see this all in the view, you will have to add a table for each unique reference table.  All of these tables will be joined with op with Left join = true so that it shows all of the values whether they match that table or not.

BradBowman_0-1666814258439.png

Then you would add each Display column to the view so that you can see the display value (along with the sys_id...) but these will each be in their own column.

BradBowman_1-1666814389187.png

This will also cause the List Collector variables with only one record/sys_id to appear in the same display value columns.  To get the List Collectors with a comma-separated list of sys_ids to appear and/or to replace the Value with the display value, you'd probably have to do something like export the view to Excel, then have an ODBC SQL connection that can run a GlideRecord query on the Reference table with the Value to return the Name (or Number, ...)

 

 

View solution in original post

Sure.  I'm not using a custom table in another instance, but this works for me to show the Database View on the RITM, so it should get you close.  Create a Relationship (System Definition > Relationships in the left nav) using your Database View in the Queries from table.

BradBowman_0-1666881173982.png

Then right-click the RITM form header and Configure > Related Lists to select this new one. 

View solution in original post

6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

You almost had it.  Try this:

BradBowman_0-1666726403380.png

With the Where clause on the second table

vo_sc_item_option=op_sys_id

Where clauses always follow the format prefix_field_name=prefix_field_name

 

Thanks Brad for your help it worked...

Can you assist for below challenge i am facing...

Now i am realizing that Options table (sc_item_option) for reference variable it stores the sys_id of record .

Eg: 

AbdulRahimShai_0-1666792722006.png

I want display value of reference variables data instead of sys_id..  

For eg i know its storing sys_id of user but how can i make it show its username??

Thanks,

AbdulRahim

 

That's going to be tricky.  To aid in this, right-click the column headers and choose Configure > List Layout to add the Question.Reference and Question.List table (for List Collector variables) to the view.  So now you can at least see the table the sys_id (or list of sys_ids) belongs to.

 

To see this all in the view, you will have to add a table for each unique reference table.  All of these tables will be joined with op with Left join = true so that it shows all of the values whether they match that table or not.

BradBowman_0-1666814258439.png

Then you would add each Display column to the view so that you can see the display value (along with the sys_id...) but these will each be in their own column.

BradBowman_1-1666814389187.png

This will also cause the List Collector variables with only one record/sys_id to appear in the same display value columns.  To get the List Collectors with a comma-separated list of sys_ids to appear and/or to replace the Value with the display value, you'd probably have to do something like export the view to Excel, then have an ODBC SQL connection that can run a GlideRecord query on the Reference table with the Value to return the Name (or Number, ...)

 

 

Thanks a bunch brad this is exactly what I wanted... 

Now is there a way to make this table data visible as related list?

I have my custom table for RITM in target instance where we are migrating these data.

in related list it should look for parent item as filter and show data ... 


Thanks,
AbdulRahim