Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Dynamic Floating Fields?

Avatar

Level 2

Hi There,

I'm still very new to LiveCycle and I've run into a problem. I have a script on a button that sends an email. I have an email 'template' text field which I populate with data inputted from a form that's filled out by the user. Now, I can get the body of the email to be the content of the text field where the email is being 'built' -- when I go to preview and fill out my form, then scroll down to the email template where all the data is being captured it's all there using floating fields, however when I click the submit by email button, it grabs the static text but not the values of the floating fields.

The script on the submit button looks like this:

var oDoc = event.target;

oDoc.mailDoc({

cTo: AutomatedEmail.fldTo.rawValue,

cSubject: AutomatedEmail.fldSubject.rawValue,

cMsg: AutomatedEmail.fldMessage.rawValue,

});

So I have the form that's being filled out, and then there is a subform which contains a text object that looks something like this:

Dear {OwnerName}

Static text Static text Static text Static text Static text Static text Static text Static text Static text Static text

Date Account Updated: {AcctUpdated}

Date Received: {Received Date}

Etc...

So when I click 'Submit by Email' It'll grab the above static text, but the floating fields it won't. Is there any way around this? My solution right now is I've basically  hard coded the entire email and grabbed all the values one by one from their text objects like so :

AutomatedEmail.fldMessage::calculate - (JavaScript, client)

var br = "\n";

var text1 = OwnerFirstName.rawValue;

var text2 = "Please accept this e-mail as confirmation that the we have received the ";

var text3 = CurrentYear.rawValue;

var text3 = "account information for";

var text4 = CompanyName.rawValue;

//Then I build the email body

this.rawValue = Text1 + "," + br + br + Text2 + " " + text3 + " " + text4 .... you get the idea.

^^ This is really long and very cumbersome when I want to make changes it takes forever. I'd like to be able to do what I mentioned above with floating fields, as that way I can just open the subform where my email template is, edit text, move floating fields around etc. The method that I'm using works, but it's just not as efficient.

Any help or maybe a better way to do this would be greatly appreciated!!!

2 Replies

Avatar

Level 10

Hi,

I don't think there is a way to get the value out of the text field with a floating field in it.

util.printf("Please accept this e-mail as confirmation that the we have received the %s account information for %s", CurrentYear.rawValue, CompanyName.rawValue)But maybe generating the email body would be easier using the util.prinf() method, so;

util.printf("Please accept this e-mail as confirmation that the we have received the %s account information for %s", CurrentYear.rawValue, CompanyName.rawValue)

You can use a string continuation character (the "\") to keep the lines short

util.printf("Please accept this e-mail as confirmation that the we have received the %s\

account information for %s", CurrentYear.rawValue, CompanyName.rawValue)

Bruce

Avatar

Level 2

Hi Bruce,

Thank you, I'll give that a try! At the very least it'll make it shorter/ cleaner. I've built a feature before where on the click of a button, I grab the content of a text field with floating fields which sits in a hidden page, except I prompt just that page to print, then when the print options window pops up I just save as PDF. I built this feature essentially to do the same thing as the email above, where I build a templated letter with information gathered from the user filled form.

Do you know if it's possible with script to print a page as PDF, save it temporarily, then grab the content of the PDF file and make it the body of an email? Because when printing, the floating fields do appear.

I know this may be a bit complicated but in theory it may work. In any case, thank you very much for the input!