Renaming uploaded file with lookup fields

I would like to rename .pdf uploaded files on the field “Document”, using some of the record fields.
Ideally it would use the RecordID but I believe that’s not possible since it’s autoincremented and the value only exists after adding the record and not during the form filling (right?).

BUT, I could use other fields. In this case, I would like to use Date, IssueID and JurisdictionID, and the last 2 are connected to lookup tables - “Issues” and “Jurisdictions”. Main table is called “Reports”
Based on another post, I’ve come to this code:

// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {

$main1 = [“IssueID”] ;
$main2 = [“JurisdictionID”] ;
$xtra = [“Date”] ;
$ext = ‘.pdf’ ;
$newDocument = $main1.$xtra.$ext ;
if ($rsnew[“Document”] != “”) {
$rsnew[“Document”] = “$newDocument” ;
}

return TRUE;
}

IF $main1 and $xtra are static text, it works like a charm.
IF I try with the above mentioned code I get “ArrayArray.pdf” (with or without using the Date field which I think it would be sketchy to use as is because of the format).


IF I use another code like:

$rsnew[“Document”] = $rsnew[“IssueID”] . “.pdf”;

I get, for example, 1.pdf instead of the lookup value for that field (eg. Accident.pdf, that corresponds to the record number 1 on the Issue Table) and I also couldn’t seem to find a way to join multiple fields.


Any help would be much appreciated. Thanks!

csmgomes wrote:

$main1 = [“IssueID”] ;
$main2 = [“JurisdictionID”] ;
$xtra = [“Date”] ;

[“IssueID”] is array of string, I believe you meant $rsnew[“IssueID”].

Yes, my bad, you’re right.
Now I get the values instead of “array” but I still get the integer values instead of the lookup table value.

IssueID (on Main Table) as integer → Related table “Issues”, should return field “IssueName” correspondent value (eg. Accident, instead of “1”)
JurisdictionID (on Main Table) as integer → Related table “Jurisdictions”, should return field “JurisdictionName” correspondent value (eg. Chicago, instead of “3”)

If you use lookup tables, the field values to be inserted are of the data type your fields (integers in your case), you may query the database to lookup yourself.

Ok, thank you