OnClick Pupup and run a Query Question

Hey All,

I have multiple pallet location (little squares) on a view with variable params tied to each location.

I would like to be able to click one of these locations have a popup come up, read the BinLocation and then run a query with that BinLocation as the parameter in the popup query table.

Any ideas?

I'm going to skip right over the fact that a Flex Repeater should probably have been used here and just get to the main question.

Inside the View you are using in the path prop, you should configure a new onClick Event which uses either the Open Popup Action or a Script Action. You should then pass in whatever params you need for your query.

Assuming you have some View (MyPopupView) which has params of Aisle and Level, you would do something like this:

system.perspective.openPopup("SomeUniqueValue", "MyPopupView", params={"Aisle": self.view.params.Aisle, "Level": self.view.params.Level})

Then your Named Query binding would supply those params within the binding.

2 Likes

And the main view would be better using a Flex container. More "Flex"ible :slight_smile: and suited for this kind of display

I am not an expert so I really appreciate all the knowledge transfer. Even though I have finished IU and have been working in Igniition for a while, some of these things are still very new to me, like the Flex. I have looked into that and I can see where that would be preferable to what I created.

I am hoping I am not wasting anyone's time but I am still a little unclear.

I am going to start from the first view and hope I can explain well enough.

I first created a view "ASRS Pallet Location". (pic1)

The bindings do not really affect anything other than the BinLocation which takes all the Aisle, Depth, Level, RackField, RackPlace, and RackSide and put them in order for the warehouse Bin. All 6 of these are manually entered later in the main view.

I then took the view/template "ASRS Pallet Location" and embedded it into the main view multiple times, I think there are 200+ of these embedded into the "ASRS_Cooler_T" view.

Next pic shows a selection of 3 of these embedded into the "ASRS_Cooler_T view".

Each ASRS Pallet Location that is embedded has its own unique BinLocation.

I also created a POPUP table "ASRS Pallet Lookup1".

The table refernces a named query "CFG Queries/asrs_pallet_lookup1" with a parameter in it looking for the BinLocation from the embedded view. I can type in a bin location and it works fine. I just cannot figure out the part of pass the variable binlocation from all the embedded view.

SELECT CONCAT(CAST(b.pos_a as CHAR),' ', CAST(b.pos_r as CHAR),' ',CAST(b.pos_xf as CHAR),' ',CAST(b.pos_xp as CHAR),' ',CAST(b.pos_y as CHAR),' ',CAST(b.pos_z as CHAR)) as "BinLoc",
       a.lpn as "LPN", a.sku as "SKU" , a.quantity as "QTY" , a.received_inducted_ts as "Timestamp" ,a.sub_status as "Status", a.dest as "Destination", a.lot_number as "Lot Number", a.Reason_Code_Last as "Reason Code", b.row_locked as "Locked Status", a.qc_status as "QC Status"
   
FROM pallets a
INNER JOIN dambach_xref b
ON a.dambach_xref_id = b.id
WHERE a.dambach_xref_id > 10000 and a.dambach_xref_id < 13000 and b.area = 2
UNION
SELECT CONCAT(CAST(b.pos_a as CHAR),' ', CAST(b.pos_r as CHAR),' ',CAST(b.pos_xf as CHAR),' ',CAST(b.pos_xp as CHAR),' ',CAST(b.pos_y as CHAR),' ',CAST(b.pos_z as CHAR)) as "BinLoc",
       a.lpn as "LPN", a.sku as "SKU" , a.quantity as "QTY" , a.received_inducted_ts as "Timestamp" ,a.sub_status as "Status", a.dest as "Destination", a.lot_number as "Lot Number", a.Reason_Code_Last as "Reason Code", b.row_locked as "Locked Status", a.qc_status as "QC Status"
    
FROM pallets a
INNER JOIN dambach_xref b
ON a.dambach_xref_id2 = b.id
WHERE a.dambach_xref_id > 10000 and a.dambach_xref_id < 13000 and b.area = 2
AND location = :lookLoc 

I am thinking that I can create a new script on each embedded view to open the popup and then have the popup execute the query above using the BinLocation from embedded view that was clicked to open.

Here is my poor attempt at the query to open the popup, which works, it just does not run the query.

I am sure it is not coded correctly...

system.perspective.openPopup("Pallet Info", "Popups/MHS Converted/ASRS Pallet Lookup1", params={"view": self.getSibling.__getattribute__('BinLocation')})

I can't help with everything in the latest post, other then to say this setup is going to be something you can't maintain long-term; this "main" view and the "template" View each need refactors and streamlining.

But to get your Popup open correctly (assuming the script lives on the Embedded View - which is a huge mistake), you need to pass each of the params as their own key in the function:

# this example ONLY passed the BinLocation param. You need to modify the params dict to include every param:value pair you want to send.
system.perspective.openPopup("Pallet Info", "Popups/MHS Converted/ASRS Pallet Lookup1", params={"BinLocation": self.props.params.BinLocation})
# this will at least send the params to the Popup correctly

Your binding dialog is displaying an error because you have not supplied any value in the expression field; it is currently supplying no value. Click the fx input, supply the relevant prop (probably {this.view.params.BinLocation}, and then make sure to hit Enter or click away so that the value is "committed".

I'd also ask your employer for a monitor with a usable resolution for developing SCADA screens. It looks like you're on 1920x1080, developing screens for the same-sized client which just doesn't work, IMNSHO. (I work on my laptop sometimes at 1920x1080, but at a fixed office (i.e. not a site office), I have a UHD and a QHD so I can actually see everything). And don't worry, it's not just your employer who doesn't understand how developing graphics on a screen the size of or smaller than your monitor's resolution is inefficient...

2 Likes

Twin 32" 4K in the office is my new minimum for productivity. I lug a spare 32" 4K to any client in driving distance.

5 Likes

I have a 27" 4K set to 100% scaling :smile: but I work from home so have to wear the costs myself (32" was like double the cost of the 27"), even if they are tax deductible... When I worked from the office though, I only had a 24" UHD and a 24" FHD, but that was FAR better than twin 24" FHDs which is the office standard...

The very first thing I would do is to reformat your SQL query so that anyone can read it without breaking something :smile::

SELECT
	CONCAT(
		' ',CAST(b.pos_a as CHAR),
		' ',CAST(b.pos_r as CHAR),
		' ',CAST(b.pos_xf as CHAR),
		' ',CAST(b.pos_xp as CHAR),
		' ',CAST(b.pos_y as CHAR),
		' ',CAST(b.pos_z as CHAR)
	) as "BinLoc",
	a.lpn as "LPN",
	a.sku as "SKU",
	a.quantity as "QTY",
	a.received_inducted_ts as "Timestamp",
	a.sub_status as "Status",
	a.dest as "Destination",
	a.lot_number as "Lot Number",
	a.Reason_Code_Last as "Reason Code",
	b.row_locked as "Locked Status",
	a.qc_status as "QC Status"
   
FROM
	pallets a
	INNER JOIN dambach_xref b
		ON a.dambach_xref_id = b.id
WHERE
	a.dambach_xref_id > 10000
		AND
	a.dambach_xref_id < 13000
		AND
	b.area = 2

UNION

SELECT
	CONCAT(
		' ',CAST(b.pos_a as CHAR),
		' ',CAST(b.pos_r as CHAR),
		' ',CAST(b.pos_xf as CHAR),
		' ',CAST(b.pos_xp as CHAR),
		' ',CAST(b.pos_y as CHAR),
		' ',CAST(b.pos_z as CHAR)
	) as "BinLoc",
		
    a.lpn as "LPN",
	a.sku as "SKU" ,
	a.quantity as "QTY" ,
	a.received_inducted_ts as "Timestamp" ,
	a.sub_status as "Status",
	a.dest as "Destination",
	a.lot_number as "Lot Number",
	a.Reason_Code_Last as "Reason Code",
	b.row_locked as "Locked Status",
	a.qc_status as "QC Status"
    
FROM
	pallets a
	INNER JOIN dambach_xref b
		ON a.dambach_xref_id2 = b.id
WHERE
	a.dambach_xref_id > 10000
		AND
	a.dambach_xref_id < 13000
		AND
	b.area = 2
		AND
	location = :lookLoc 

Upon which I now realise that you are unioning basically the same query twice. You should just combine these into one and use as the last where condition

AND
   (b.area = 2 OR location = :lookLoc)

In the U.S., it is difficult for individuals to deduct non-reimbursed work expenses. It is much easier for a business owner to deduct expenses for work hardware, even if placed in a residence. (:

{ So totally off-topic. }

4 Likes

Thank you for helping me, I really do appreciate it.

If opening the pop in the embedded view is a mistake, what would be a good alternative?

The View being embedded should be responsible for opening the Popup. In your case: Popups/MHS Converted/ASRS Pallet Lookup1 should have an Event which opens the Popup, instead of configuring each and every one of those Embedded Views to open a Popup - this is a primary goal of templating and is a design pattern you MUST get comfortable using in Perspective.

This is what I originally set up. I cannot figure out how to pass that BinLocation to my popup in order to execute the popup query.

This is how, assuming you've setup the param correctly.

Thsi is working great, thank you so much for your patience and help.

One question, I tried adding that onclick script to my my template for the pallet location and it did not work. Is there a trick to that or cannot that not be done?

It should work on your template, but you have to account for where the click will occur. If the View being used is just a root container with some backgroundColor applied, the Event should be on the root - if the View contains some other component inside of the root, then the Event should go onto whichever component is going to be receiving the click.