Highlighted

Can't get LiveCycle to show/hide subform

Avatar

Guest

21-05-2008

Hi,



I am new to LiveCycle and am developing a quote PDF. Couple of issues with it are:



I have 4 textfields, and for each one, if someone enters a value into it, I want the subform for tha field to appear. Can't seem to get that to work with presence function.



Is there a way to change what people put in fields to sentance or title case?



Most of my quote form is completed internally and we will save the PDF with the input we put in there, and attach it to an email to our clients. We want most of the fields in the PDF to display as text not fields when clients open the PDF, so that they can't change them.



There are 4 fields that we want them to be able to use to OK the quote with 2 buttons, 1 to print it out and the other to email the PDF back to us with their OK.



Can this be done? We have already designed this quote form PDF with all the fields in LiveCycle so I can send it to anyone who wants to look to see if they can help me out.



Much appreciated!

Replies

Highlighted

Avatar

Guest

22-05-2008

First up, this document is quite handy and would help answer most of your questions: http://help.adobe.com/en_US/livecycle/es/LiveCycle_Designer_Scripting_Basics.pdf



"presence" is a property, not a function, so you need to do the following:



yourSubFormName.presence = "hidden";

yourSubFormName.presence = "visible";



You can change to title case but will need to find or write a JavaScript function to do this. Call this function from the Exit event of the field, ensuring that the language selected is JavaScript. To add a script, right click on the subform or main form and select Insert Script Object. Give that script block a name (such as "stringFunctions", then add the following to it:



function toTitleCase(inStr) {

var str = "";

var wrds = inStr.split(" ");

var wrdsLen = wrds.length;



for (var i=0; i < wrdsLen; i++) {

str = str + " " + wrds[i].substr(0,1).toUpperCase() + wrds[i].substr(1,wrds[i].length);

}

return str;

}



In the field you are interested in, select the Exit event, ensure the language is JavaScript and type the following:



this.rawValue = stringFunctions.toTitleCase(this.rawValue);



When you exit the field, the sentance will be title case. You will obviously have to extend the toTitleCase script to be cleverer if you are dealing with people's names (e.g. McKay, Van de Linden, etc).



Adobe provided a great script that locks down the document - see page 422 of http://help.adobe.com/en_US/livecycle/es/lcdesigner_scripting_reference.pdf (title is called "Getting the fields from each page". You should put this in the "docReady" event on your root form (defaults to "form1"). You should extend your form so that a hidden field stores the required state (locked or open) and this is updated before the form is e-mailed. You should then extend the lockdown script to only execute if that field's value is set to locked.



You can definitely do everything you've described with LiveCycle.



Have a look at the documents and see how you go.



John.
Highlighted

Avatar

Guest

10-06-2008

Hi John,



I can't seem to work out how to do what you are saying. I have uploaded the PDF file to www.bluebaboon.com.au/Quote Letter.pdf



Would you be able to download it and show me how to do it with one and then I can look at it and work out how to do it for the others.



If you are able to put a script on the form textfield called quantity2 so that when a value is entered into it production2, GST2 and total 2 become visible. When there is no value in quantity 2 we want those 3 fields hidden. Then I can look at it and work out how to do it for the others.



We've decided not to worry about the text to CAPS, it's too difficult.



But if you can show me how you would do the lock down that would be fantastic.



Thanks heaps, I really appreciate it!
Highlighted

pguerett

11-06-2008

I had a look at your form and here is what I found:



To get the upper function working it is a lower case upper as the command.



The code you want on your quantity2 command is:



if(quantity2.rawValue == null){

app.alert("invisible");

production2.presence = "invisible";

}else {

app.alert("visible");

production2.presence = "visible";

total2.presence = "visible";

GST2.presence = "visible";

}



After doing this it still did not work. I do not know what you did but it looks like your template is corrupted. I select all and copied to a new template and it worked.



To lock everything down I suggest that you do something like this.

Create a scriptObject and put this function in it.

You can create a scriptObject by highlighting the Page subform and right click (choose the Insert Script Object option). At the bottom of the heirarchy view will be a Variables section and inside there is your script object. Rename it to myScriptObject. Paste this code into it (note that because it is a script object there are no events to choose):



/*************************************************************************************

Function: LockAllFields

Description: This function will lock all fields.

IN: The parent subform. It could also be an element that contains subform like form1

OUT : nothing

**************************************************************************************/

function LockAllFields(myParentObject){



var allChildElements;

var intNumElements;

var currentElement;

var j;

var k;



//Get all the child nodes of the parent element

allChildElements = myParentObject.nodes;



//Total number of element in the object

intNumElements = allChildElements.length;



//Loop through all the child elements

for(j=0; j< intNumElements;j++){

currentElement = allChildElements.item(j);

//If the element is another subform we'll recusively call the function again

if(allChildElements.item(j).className == "subform"){

LockAllFields(currentElement);

}

//If the objects are fields and they are set to mandatory (validate.nullTest) then we will set the border.fill.color - dependant on object type

else if(currentElement.className == "field"){



currentElement.access = "readOnly";



}

//Check for exclusion groups - Radio Buttons

else if(currentElement.className == "exclGroup"){

for(k=0; k< currentElement.nodes.length;k++){

if(currentElement.nodes.item(k).className == "field"){

//set the color for the radio buttons individually

currentElement.access = "readOnly";

}



}

}

}

}//end function



Now to call this function you would use the command:



ScriptObjectName.FunctiontoCall(node to start the locking process from)



So in your case it woudl look like this:



myScriptObject.LockAllFields(form1);



Let me know how it works out for you.



Give that a try and let me know that it worked for you.
Highlighted

Avatar

Guest

11-06-2008

Hi Paul,



I am trying to do the first part about the quantity 2 showing and hiding and can't seem to get it working even when I create a new form document with 3 new text fields called those names. I presume it is suppposed to be Javascript, but on which do I place that script? Exit, change or calculate?



Would you be able to email me your test PDF to caleb@bluebaboon.com.au?



Thanks heaps!