Skip to main content
The Right Way, LLC
Participant
June 29, 2023
Answered

Properties: Need Script/Coding, Currency and Regular Copy

  • June 29, 2023
  • 3 replies
  • 1705 views

Hi there! I am in desperate need of help with possibly some type of coding to customize what we need several of our fields to do. 

 
I have a document that the field we have created for our employees that have  a "Sales Listing Price". On this field we need the format to always contain 'Number' with currency symbol '$'. However, we also need this field to allow us to type words such as "N/A" or "Unknown". 
 
The issue currently is that we can only have one or the other and we don't have the knowledge to make this change. Any help on this will be a HUGE help and greatly greatly greatly appreciated. 
 
Thank you for any help and attempts in advance 🙂 
This topic has been closed for replies.
Correct answer try67

You will also need a custom Validation script to only allow the values you want the user to enter (ie. a number or on of the terms from a list you've approved in advance).

3 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 30, 2023

You will also need a custom Validation script to only allow the values you want the user to enter (ie. a number or on of the terms from a list you've approved in advance).

JR Boulay
Community Expert
Community Expert
June 30, 2023

You should use this script as a custom format script:

if (!isNaN(event.value) && event.value != event.target.defaultValue) {event.value = "$" + event.value;}

 

Acrobate du PDF, InDesigner et Photoshopographe
The Right Way, LLC
Participant
July 5, 2023

Oh my. Thank you SO much! This worked perfectly! 

I have one more question that perhaps you may be able to assist me with. With this script, is there a way to add the ability to auto-generate a "comma" when a currency is entered.

 

I.e. $1234 would actually read $1,234. 

At this time, if I manually enter in "1,234", it will stay as that. Rather than generating $1,234. 

 

Either way, I genuinely appreciate your help and time with this! Grateful, grateful, grateful. 

Nesa Nurani
Community Expert
Community Expert
July 5, 2023

Change last line to:

event.value = util.printf("$%,0.0f",event.value);

 

You can also set the number of decimals, for example if you change 0f to 2f it will show two decimals...etc

Nesa Nurani
Community Expert
Community Expert
June 30, 2023

You can use Custom format script.