This topic is locked
[SOLVED]

 Set Custom Upload Folder Path based on Field Value

6/2/2017 3:04:28 PM
PHPRunner General questions
S
seedavidwork author

Similar to the example of using a session ID to set the Custom Upload Folder

( Example from phprunner is --- $folder = "userfiles/".$_SESSION["UserID"]; )

I want a custom path where the folder path is based on the "job_id" value from the record I am currently editing.

I am sure this is simple, but I have tried different methods of trying to set a variable from the edit page 'before display' and 'before record update' events without any success.

Y
YCH 6/3/2017



Similar to the example of using a session ID to set the Custom Upload Folder

( Example from phprunner is --- $folder = "userfiles/".$_SESSION["UserID"]; )

I want a custom path where the folder path is based on the "job_id" value from the record I am currently editing.

I am sure this is simple, but I have tried different methods of trying to set a variable from the edit page 'before display' and 'before record update' events without any success.


Just an idea: get the Job_id field value with
$data = $pageObject->getCurrentRecord();
$myjobid = $data["Job_id"];
Use $myjobid in your custom path.

Y
YCH 6/3/2017



Similar to the example of using a session ID to set the Custom Upload Folder

( Example from phprunner is --- $folder = "userfiles/".$_SESSION["UserID"]; )

I want a custom path where the folder path is based on the "job_id" value from the record I am currently editing.

I am sure this is simple, but I have tried different methods of trying to set a variable from the edit page 'before display' and 'before record update' events without any success.


Just an idea: get the Job_id field value with
$data = $pageObject->getCurrentRecord();
$myjobid = $data["Job_id"];
Use $myjobid in your custom path.

S
seedavidwork author 6/3/2017

I tried adding the suggested code to the custom folder area, and to several different event areas without success. Could you elaborate on where this code needs to be inserted to have the correct result.
In Custom Folder I have

$folder = "userfiles/".$myjobid;
In Events ( I have tried several ) I have
$data = $pageObject->getCurrentRecord();

$myjobid = $data["job_id"];
Thanks for the help

S
seedavidwork author 6/3/2017

I eventually solved this by creating a session variable and using this variable in the custom folder path..
In the process record event..

$_SESSION["shiz"] = $data["job_id"];
in the custom folder path

$folder = "userfiles/".$_SESSION["shiz"];
where ["job_id"] was the field I wanted the value from and $_SESSION["shiz"] was a variable I made up to store the value ( ["shiz"] could be anything)
The uploaded files are saved to /userfiles/jobid within my application directory
This process seems to require a session variable and not a regular variable to work...