mindtpi99 Posted December 13, 2007 Posted December 13, 2007 (edited) Hi What I've done is to create a page with two record sets: From a results page you click on a link to the client record. The client record page has two record sets on it; the client detail (from the clients table) and all jobs linked to that customerID (from the Jobs table). When you click on a link, if there are jobs against that client, everything displays fine, however, if there are no linked jobs for a client the jobs record set returns goes to the error page and gives a 401 error . How do I get it to suppress that error and still display the client detail from the clients table whether there are linked jobs or not? I would have just used a portal but need record set paging and this doesn't seem to work for portals. Alternatively, is there a way I can trap the 401 error and ignore it? Any suggestions gratefully accepted!! Here is the PHP code I'm using: <?php require_once('Connections/PressLogin.php'); ?> <?php // get variable from URL and set to $Variable $ActiveJobs = $_GET['ActiveJobs']; ?> <?php $PressLogin_find = $PressLogin->newFindCommand('Clients_Web'); $PressLogin_findCriterions = array('KP_CustomerID'=>'=='.fmsEscape($_GET['KP_CustomerID']),); foreach($PressLogin_findCriterions as $key=>$value) { $PressLogin_find->AddFindCriterion($key,$value); } $ActiveJobs_find = $PressLogin->newFindCommand('Jobs_Web'); $ActiveJobs_findCriterions = array('ActiveStatus'=>$ActiveJobs,); foreach($ActiveJobs_findCriterions as $key=>$value) { $ActiveJobs_find->AddFindCriterion($key,$value); } fmsSetPage($PressLogin_find,'PressLogin',10); fmsSetPage($ActiveJobs_find,'ActiveJobs',10); $PressLogin_result = $PressLogin_find->execute(); $ActiveJobs_result = $ActiveJobs_find->execute(); if(FileMaker::isError($PressLogin_result)) fmsTrapError($PressLogin_result,"error.php"); if(FileMaker::isError($ActiveJobs_result)) fmsTrapError($ActiveJobs_result,"error.php"); fmsSetLastPage($PressLogin_result,'PressLogin',10); fmsSetLastPage($ActiveJobs_result,'ActiveJobs',10); $PressLogin_row = current($PressLogin_result->getRecords()); $ActiveJobs_row = current($ActiveJobs_result->getRecords()); $ActiveJobs__Clients_portal = fmsRelatedRecord($ActiveJobs_row, 'Clients'); $ActiveJobs__JobsActiveJobs_portal = fmsRelatedRecord($ActiveJobs_row, 'Jobs_ActiveJobs'); // FMStudio v1.0 - do not remove comment, needed for DreamWeaver support ?> Edited December 13, 2007 by Guest Added Code Tags
Genx Posted December 13, 2007 Posted December 13, 2007 It looks to me like your returning all active jobs - not those that are related to your client...
mindtpi99 Posted December 13, 2007 Author Posted December 13, 2007 The active jobs field is basically a calculation that concatenates the CustomerID with an active job identifier and this is used to create the relationship. If there is an active job for the client it works perfectly, however, if there isn't, the ActiveJobs recordset generates and error and sends it to the error page - I want it still display the client detail page.
Genx Posted December 13, 2007 Posted December 13, 2007 Remove this line: if(FileMaker::isError($ActiveJobs_result)) fmsTrapError($ActiveJobs_result,"error.php"); Put this around the last three lines: if( !FileMaker::isError($ActiveJobs_result) ) { } e.g. if( !FileMaker::isError($ActiveJobs_result) ) { $ActiveJobs_row = current($ActiveJobs_result->getRecords()); $ActiveJobs__Clients_portal = fmsRelatedRecord($ActiveJobs_row, 'Clients'); $ActiveJobs__JobsActiveJobs_portal = fmsRelatedRecord($ActiveJobs_row, 'Jobs_ActiveJobs'); }
mindtpi99 Posted December 13, 2007 Author Posted December 13, 2007 Thanks for that - it now at least starts to load the page, but doesn't display any content below that - but it feels like progress!! I've attached a screen shot so you can see what I mean
Genx Posted December 13, 2007 Posted December 13, 2007 I really can't help without seeing some more code.. The above code runs a search and that's it, the output isn't there and so I can't really tell you what's going on.
mindtpi99 Posted December 14, 2007 Author Posted December 14, 2007 Thanks for that - I've attached the page client_details.php.zip
Recommended Posts
This topic is 6452 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now