Expand my Community achievements bar.

Radio button to determine what text is put into the body of an email

Avatar

Level 1

Hi all,

I need some help with a radio button and java scripting. This is the code I'm using on a button with a mouse up event using Java script run at the client

var oSubmit = this.resolveNode("$..#submit");

var cToAddr = "abc@sdf.org";

var cCCAddr = "abc@sdf.org";

var cSubLine = "Security Access Authorization";

var cBodya = "Dear Help Desk," + "\n" + "\n" +

"This email serves as my electronic approval for " + "\n" + "\n"

 

var cBodyb = "============ SECURITY ACCESS REQUEST DETAILS ================" + "\n" + "\n"

var cBodyc = (EffDate.length = "")

  if(EffDate.rawValue)

cBodyc = "Effective Date - " + EffDate.formattedValue + "\n" + "\n"

 

var cBodyd = (RadBut.length == "2")

  if(RadBut.rawValue)

cBodyd = "Status - Create New User Account" + "\n" + "\n"

 

var cBodye = (RadBut.length == "3")

  if(RadBut.rawValue)

cBodye = "Status - Add/Remove Access" + "\n" + "\n"

 

var cBodyf = (RadBut.length == "5")

  if(RadBut.rawValue)

cBodyf = "Status - Terminate" + "\n" + "\n"

 

var cBodyg = (RadBut.length == "1")

  if(RadBut.rawValue)

cBodyg = "Status - Department Transfer from " + "\n" + "\n" 

 

var cBodyh = (RadBut.length == "4")

  if(RadBut.rawValue)

cBodyh = "Request to have name changed to - " + "\n" + "\n";

oSubmit.target = "mailto:" + cToAddr + "?cc=" + cCCAddr

+ "&subject=" + cSubLine

+ "&body=" + cBodya + cBodyb + cBodyc + cBodyd + cBodye  + cBodyf  + cBodyg + cBodyh ;

this is the test layout I'm using

1.JPG

2.JPG

No matter what I try, it always put all of the choices in the body of the email, not just the one I checked. any help would be greatly appreciated...Thanks Erick

1 Reply

Avatar

Level 4

First off welcome to the group! Livecycle can be an interesting program.

For me I am not very technically proficient in coding so I tend to gravitate to, how you say, less than elegant solutions. What I do is create an Email Submit button for each Radio button. Then I create a dummy Email Submit button (this part will be key later). From the Object Library view on each Email Submit button I set the Email Address and Email Subject that I want. Then I hide all of the Email Submit buttons with the exception of the dummy Email Submit button. From the Action Builder I then create an action on the dummy Email Submit that when the button is clicked to open a dialog box to say "Please Select an Option". I then create an action within the Action Builder on each Radio button to show the corresponding Email Submit button that has the subject line I need while also making sure to hide the dummy Email Submit button (and any other buttons if the user clicks several radio buttons). That worked for me in the past. Then I added a DocuReady event on the dummy Email Submit button to make sure it was visible and the other buttons were hidden once the form was open. Sort of a reset if you will. The downside is if the user changes nothing they still get a prompt to save the changes. I am sure that some of our more advanced coders can offer a fix to your code lines, but that is sort of the non-coder way to go about this.

Edit: Oh I forgot to say that if you want the buttons to appear the same to the user, just overlay them together. To the user there is no change.