Forum

Thread tagged as: Forms

Perch Forms App - add 3 letter prefix to the 'responseID'

Hey guys,

Using the Perch Forms App, is it possible to add a 3 letter prefix to just the 'responseID' of each of the 3 forms I'm using?

The responses need to be imported into an Accounting Software package via the CSV download and I have now been asked by the client to add in the 3 letters.

Cheers

Steve Hopper

Steve Hopper 0 points

  • 4 years ago

see this as it may help...

https://docs.grabaperch.com/templates/form/form/

Look at "perch:form attributes" section for prefix

Thanks Robert, unfortunately that prefix tag doesn't apply to the 'responseID' in the database, only the new fields you build in your form.

Steve, I want to help here, so additional details are needed... (EDITED: better wording)

When I run the CSV Export the responseID is not included in the csv now (with or without prefix) so just using a dummy line from your current CSV, could you please show me what you're expecting. It would be quite simple to build a export app to output your CSV exactly as you wish... just provide a (Now) sample, and a (Required) sample.

Thanks, and I will see what we can do...

(EDIT)

my sample output:

date,ip_address,first_name,last_name,address,city,state,zipcode,email,phone_home,phone_mobile,occupation,employer,employer_address,phone_work,status,church,church_location,citizenship,profileID,upload
"2017-09-06 17:44:47","192.168.2.200","Robert","Ketter","First Street","Hedgesville","West Virginia","25427","robert@adomain.us","3045551212","3045551213","lorem","lorem","lorem","lorem","Married","lorem","lorem","USA","","1504734287loandocument.pdf"

Hey Robert, Thanks for getting back to me. Apologies if you thought I was being sharp.

Here is a line from my current CSV output for one of my forms:

responseID,date,ip_address,DeceasedTitle,DeceasedLastName,DeceasedFirstName,DeceasedMiddleName,TermsConditions

"431","2017-09-07 14:39:48","163.47.229.187","Miss","Kempy","Angela","Alison","Yes",

What I need to achieve is the 3 letter and dash prefix on the responseID:

responseID,date,ip_address,DeceasedTitle,DeceasedLastName,DeceasedFirstName,DeceasedMiddleName,TermsConditions

"MLC-431","2017-09-07 14:39:48","163.47.229.187","Miss","Kempy","Angela","Alison","Yes",

On line 40 of 'responses.export.pre.php' in 'perch_forms > modes', I can add in one prefix to the output of the responseID. But now they have 3 separate forms so that wont work anymore.

I'm using Perch 3.0.8 and Forms 1.9.1

Eventually I need to set up a cron job to export the CSV files to an FTP site so that the Accounting Software can pick them up, check them, import them and then delete the CSVs when done.

Thanks

On line 40 of 'responses.export.pre.php' in 'perch_forms > modes'

OK, so I didn't hear that....lol ... A Modified App

Steve, I am on Forms 1.9.1 on the server I just tried, so I am going to look into the fact that your CSV includes responseID and mine does not...

That being said, creating a simple app is the solution here NOT modifying the existing one. The custom app could easily query the forms data and create a "List" of forms, then provide a "export" of the responses. There are a couple ways to add the prefix... I would add this prefix via settings in the custom app at export runtime.

Otherwise I am out of options in my head... and I am off to find out why the responseID is not included in my export...

Hey Robert, Thanks for getting back to me. Apologies if you thought I was being sharp.

No, Steve... I didn't... and reading back to my reply I can see why you would have thought I felt that way... I didn't re-read my response and now that I have I see it's badly worded and I am going to edit that now. :)

Pretty sure you could achieve this with some js on validation ... something like this

window.onload = function() {

  document.getElementById('theForm').onsubmit = function() {
    var txt = document.getElementById('responseID');
    txt.value = "MLC-" + txt.value;
  };
};​​ 

Can't vouch for it but is a rough pass that i'm sure you could improve upon.