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!