Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Don't print empty fields...?

Avatar

11-06-2008

I need a little help... I am creating a User Request Form and i would

like the form to print only with the fields/boxes that are checked or

filled. I am not too experienced with scripts so i was looking for some

advice and or where i could find out how to accomplish this. Many

thanks!

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

12-06-2008

You will have to get a list of all objects on the form, test then one by one to make sure you have a field, see if the field is empty and if so then set it to be Visible (screen only).



This script is not trivial for a non-programmer. If you want to try it here is the basis for creating a script object that will allow you to get all fields and set the relevant property to -print so that it will be excluded from the print. This is a function meant to go into a scripting object. To call the scripting object use:



scriptobjectname.NoPrintEmptyFields(form1);



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

Function: NoPrintEmptyFields

Description: This function will set all empty fieldsso that they will not print.

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

OUT : nothing

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

function NoPrintEmptyFields(myParentObject){



var allChildElements;

var intNumElements;

var currentElement;

var j;



//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 empty then we will set the relevant property to -print

else if((currentElement.className == "field") && (currentElement.rawValue == null)){



currentElement.relevant = "-print";



}

//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 relevant property for the radio buttons individually

currentElement.relevant = "-print";

}



}

}

}

}//end function