Highlighted

Append prefix to auto-generated number

New Here ,
Nov 01, 2020

Copy link to clipboard

Copied

Hello All 

 

Hoping someone can help with this: 

I have a form that has two functions: as a demo loan form and a delivery note form. You can select which form type you are filling out by selecting one of those options in a dropdown field called "DocType". 

At the moment the form is automatically adding a document number going up incrementally each time a new instance of the form is opened. What I would really liek to do is add a prefix to this number based on the DocType selected. So say "DN" for deliver note and "DEMO" for demo loan. Ideally the number would also be linked to the form type; so DN numbers increase independantly of DEMO numbers, but I can live with a global number that just increments by one each time. 

Also the increment occurs when the "Save As" button is selected on the form but I'm thinking it would be better to increment when the DocType selection is made.

 

Hoping that all makes sense.

 

TOPICS
Create PDFs, How to, PDF forms

Views

62

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Append prefix to auto-generated number

New Here ,
Nov 01, 2020

Copy link to clipboard

Copied

Hello All 

 

Hoping someone can help with this: 

I have a form that has two functions: as a demo loan form and a delivery note form. You can select which form type you are filling out by selecting one of those options in a dropdown field called "DocType". 

At the moment the form is automatically adding a document number going up incrementally each time a new instance of the form is opened. What I would really liek to do is add a prefix to this number based on the DocType selected. So say "DN" for deliver note and "DEMO" for demo loan. Ideally the number would also be linked to the form type; so DN numbers increase independantly of DEMO numbers, but I can live with a global number that just increments by one each time. 

Also the increment occurs when the "Save As" button is selected on the form but I'm thinking it would be better to increment when the DocType selection is made.

 

Hoping that all makes sense.

 

TOPICS
Create PDFs, How to, PDF forms

Views

63

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 01, 2020 0
Engaged ,
Nov 02, 2020

Copy link to clipboard

Copied

One of the ways to do this would be to make 2 hidden fields one named "DN" and 2nd named "Demo" then
use this script in "DocType" field as "Custom Validation Script";
if(event.value == "Deliver note"){
this.getField("DN").value += 1;}
else if(event.value == "Demo loan"){
this.getField("Demo").value += 1;}

Then in field where you want to show DN number (lets call it "DN Number" field for example) use this script as Custom Calculation Script":
event.value = "DN " +this.getField("DN").value;
Then in field where you want to show Demo number (lets call it "Demo Number" field for example) use this script as Custom Calculation Script":
event.value = "DEMO " +this.getField("Demo").value;

TIP: if you want to show your number as DN: 1 add : in the code like this: event.value = "DN: " +this.getField("DN").value;
or if you want to show like this DN - 1 add: event.value = "DN - " +this.getField("DN").value; ...etc

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

Thanks for the feedback. This gets me close. I'm just having a couple of issues. 

 

Selecting either Demo Loan or Delivery Note gives me the correct prefix now, but selecting the different options just adds that prefix and doesn't increase the number. So I get:

DNDNDNDNDNDN111

or

DEMODEMODEMODEMODEMO111

 

Here's my code in case I'm missing something:

///in the custom validation script box in the DocType Field

if(event.value == "Delivery Note"){
this.getField("DN").value += 1;}
else if (event.value == "Demo Loan"){

this.getField("DEMO").value += 1;}

 

///in the custom calculation script box in the DN/DEMO Field

event.value="DN"+this.getField("DN").value

 

event.value = "DEMO" + this.getField("DEMO").value

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 02, 2020 0
Engaged ,
Nov 02, 2020

Copy link to clipboard

Copied

It's working fine on my end. Can you share your file?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 02, 2020 0
Engaged ,
Nov 02, 2020

Copy link to clipboard

Copied

You didn't create hidden fields.

here is your file updated.

https://drive.google.com/uc?id=10M-jZK9qHNuGKjR2jF9_kqFzium2-F4q&export=download 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

Amazing!!! Thank you very much

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 02, 2020 0