Expand my Community achievements bar.

SOLVED

data formatting question

Avatar

Former Community Member

I have one field for SSN or EIN number. The xml output needs to be in either 123-45-6789 or 12-3456789 format depending on if the entity is a person or a business. I have a couple other fields I can likely use to trigger one format over the other but I'm not sure if I can selectively format one field multiple ways.

Is this possible and if so, does anyone have a sample or script that could do this?

I do know that I could display messages, validations and such to the field but it would be a better user experience if it was formatted on the way out that way the users could enter the data any way they were comfortable. Thanks for any suggestions!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I made a couple of tests and it looks like changing the picture clause for text objects has no effect at all.

It also doesn't work when you use alternative picture clauses with different locale settings

So, the only way I found is to format the data with the Format() method in FormCalc.


var source = $.rawValue


var formattedSource



if (AcctOpenProcesssubform.CSSystemSetupForm.Account_Client_Info.personalCust_domicile.US_Citizen.rawvalue eq "us") then


  formattedSource = Format("XX-XXXXXXX", source)


else  


  formattedSource = Format("XX-XXX-XXXX", source)


endif



$.rawValue = formattedSource


View solution in original post

7 Replies

Avatar

Level 10

Hi,

you can use a script to change the bind pattern dynamically.

The XML souce will look this way if you alrady definded such pattern.


<field name="field1" … >


    <bind>


          <picture>XXX-XX-XXXX</picture>


    </bind>


</field>


The script can look like this:


field1.bind.picture.value = checkBox.rawValue === 1 ? "XXX-XX-XXXX" : "XX-XXXXXXX";


The X allows digits and characters. If you only use numbers replace it with 9 such as 999-99-99999.

Avatar

Former Community Member

radzmar, thanks for the response.

The field that i have to trigger one format over the other is an exclusion group consisting of 2 radio buttons. I tried to meld the sample code into my fields but I'm getting an error indicated it is not defined. I tried the group, then the radio button in place of the checkbox object in your sample.

Sorry if this is basic stuff but I am very much struggling to stay afloat with scripting.

Avatar

Level 10

Please share your form.

It's not easy to answer your question without seeing how the form is designed.

Avatar

Former Community Member

Unfortunately, I dont have a version I can share at this point. It is 72 pages long and full of corporate branding which my employer does not want outside the company. I hope I can explain the structure well enough to get some feedback.

I have the script in the change event of the field where the SSN/EIN is entered. The radio buttons are in a different subform
Here is a section of the xml source for the field where the ssn/ein is entered.

<field name="SSNTax_ID_No_Acct_Level_021" w="30.532mm" h="2.984mm" y="3.923mm" x="135.055mm">
               <ui>
                  <textEdit>
                     <margin/>
                  </textEdit>
               </ui>
               <para vAlign="middle"/>
               <font size="7.5pt" typeface="Arial"/>
               <assist>
                  <toolTip>Type SSN, Tax ID No. or "Applied For" (Irrev Tr), as applicable, HERE.</toolTip>
               </assist>
               <traversal>
                  <traverse ref="Tax_Year_End_IRAs__1231[0]"/>
               </traversal>
               <border>
                  <edge/>
                  <corner thickness="0.175mm"/>
               </border>
               <bind>
                  <picture>text{999-99-9999}</picture>
               </bind>
               <event activity="change" name="event__change">
                  <script contentType="application/x-javascript">AcctOpenProcesssubform.CSSystemSetupForm.CM_tax_info.SSNTax_ID_No_Acct_Level_021.bind.picture.value = AcctOpenProcesssubform.CSSystemSetupForm.Account_Client_Info.personalCust_domicile.US_Citizen.rawvalue === us ? "XXX-XX-XXXX" : "XX-XXXXXXX";

</script>
               </event>
            </field>
            <draw name="T61" w="1.129in" minH="2.984mm" y="3.923mm" x="106.113mm">
               <value>
                  <text>SSN/Tax ID No. (Acct Level):</text>

Any suggestions will be appreciated. Thanks!

Avatar

Correct answer by
Level 10

Hi,

I made a couple of tests and it looks like changing the picture clause for text objects has no effect at all.

It also doesn't work when you use alternative picture clauses with different locale settings

So, the only way I found is to format the data with the Format() method in FormCalc.


var source = $.rawValue


var formattedSource



if (AcctOpenProcesssubform.CSSystemSetupForm.Account_Client_Info.personalCust_domicile.US_Citizen.rawvalue eq "us") then


  formattedSource = Format("XX-XXXXXXX", source)


else  


  formattedSource = Format("XX-XXX-XXXX", source)


endif



$.rawValue = formattedSource


Avatar

Former Community Member

Radzmar that worked! Thank you!
I put that in the exit event of that SSN/EIN field. I had it in the change event but that wasnt working.

I really have a tough time deciding the best place to put scripting. Some are quite obvious...click event for a button, but some of the most complicated things throw me off. Is there a rule of thumb or best practice documented somewhere?

I have several documents and am trying to read as much as possible but I dont recall seeing anything directed as a best practice.

Thanks again!

Avatar

Level 10

Hi,

finding the right event for an action is often a challenge.

To understand how and when events fire, you should use Niall's tool

How often events fire and their sequence | Assure Dynamics developing dynamic LiveCycle and Flex sol...

Also, there are a couple of very good samples forms.

Code solutions | Assure Dynamics developing dynamic LiveCycle and Flex solutions

And finally the XFA specs.

http://partners.adobe.com/public/developer/en/xml/xfa_spec_3_3.pdf