If you want to add more than simple statements such as ' user = " . $_SESSION["OwnerID"] in the WHERE area of lookup fields, you can add custom functions to be included as well :-)
For example:
- I needed to use a custom query string (EpicID) I automatically add to certain dashboard pages, and I needed the lookup in a add popup-up form to be filtered by that query string parameter.
- Unfortunately, since we were using an add popup form in dashboard, I could not simply use ' EpicID = " . $_GET['EpicID']' because that query string was bound to the dashboard url and not the popup's url
- Simply adding ' EpicID = ". $_SESSION['EpicID'] ' to the where statement would work, except the user runs the risk of incorrect $_SESSION['EpicID'] being used in a scenario where they have the same page opened multiple times while viewing different dashboards with different query string parameters. The $_SESSION['EpicID'] could be overwritten as each dashboard loads, and consequently if a page refresh doesn't take place before hitting add new popup in one of those dashboards we run the risk of making use of the other dashboards session.
- In order to solve this I added the following function to AfterApp Initialized Event:
function lookupEpicID_QueryString(){
$query = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
$params = array();
parse_str($query, $params);
if (isset($params['EpicID'])) {
$epicID = $params['EpicID'];
}else{
$epicID = "";//empty (basically show all stories regardless of epic.
}
return $epicID;
};//end function lookupEpicID_QueryString
- Then in the lookup field's WHERE filter I added ' LinkEpicID = " . lookupEpicID_QueryString();'
- Hence, now when that lookup field loads it can dynamically parse the URL query tring of the parent dashboard and filter my lookup correctly without worrying about $_SESSION vars getting crossed
This trick an also be used to create other custom functions for use in the where statement!
Cheers,