I am a completely green user of LiveCycle. I am trying to make a form for my husband to your for his small business. But I have a problem which I hope you could help me to solve. So what I am trying to achieve is to make a 5 digit code which will become a costumer number. The idea is to make it of the costumer company real name. I want to take the first 4 letter of the company name and convert them to a number. Plus add a leading 0 (zero) to it. I haven’t really made up my mind on what number each letter should represent but it is now what I need you to help me. So let’s say that the system is A,B,C=1 D,E,F=2 etc.
1: I made a drop-down list with the companies’ names.
2: I created a costumer number text field where the 5 digit code should appear.
3: I made a code in FormCalc and it is as follow:
OffertenGiltig.#subform[0].Header.KundNummer::calculate - (FormCalc, client)
KundNummer[0]=""
if (HasValue(Företagsnamn[0])) then
var Forkortning=Replace(Företagsnamn, " ", "")
Forkortning=Replace(Forkortning, "-", "")
Forkortning=Replace(Forkortning, ".", "")
Forkortning=Upper(Substr(Forkortning, 0, 4))
Forkortning=Replace(Forkortning, "A", "1")
Forkortning=Replace(Forkortning, "B", "1")
Forkortning=Replace(Forkortning, "C", "1")
Forkortning=Replace(Forkortning, "D", "2")
…
Forkortning=Replace(Forkortning, "Z", "8")
Forkortning=Concat("0", Forkortning)
endif
I know that there is surly a nicer way of making this could. But it actually works. The problem is that when the form is opened and as long as no company name is chosen in the drop-down window the value of the KundNummer is “0” which is an irritating detail. I would like it to be empty (NULL). I was hoping that the IF statement was doing the trick but NOT. Can you help me?
I am also open for all suggesting is how to make my code unique. In other words make sure that no company names get the same 5 digit combination.
Try this variation, without the instance id
if (HasValue(Företagsnamn)) then
... Same code ...
else
KundNummer =""
endif
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script