• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Alert for drop down selections

Engaged ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

I'm trying to figure out how to apply a custom calculation script similar to how I did it for something else, but I'm having a hard time with it.  I attached a document that hopefully explains more clearly what I'm trying to do.  I tried to add the following custom calculation script in the absence type drop down, but I'm obviously doing something wrong because it doesn't work

if((event.value != "") && (this.getField("ActingRateJob1Emp1").valueAsString == this.getField ("ActingRateJob1Emp1")){ app.alert("Do not enter acting rate with absence time",3); event.value = "";}

TOPICS
JavaScript , PDF forms

Views

459

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

You're comparing a field to a string.

Change this:

this.getField("ActingRateJob1Emp1").valueAsString == this.getField ("ActingRateJob1Emp1")

To:

this.getField("ActingRateJob1Emp1").valueAsString == this.getField ("ActingRateJob1Emp1").valueAsString

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

Also, just noticed that the field names in both sides are the same, so you're comparing something to itself there...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

I find these alerts so confusing.  The alert pops up every time the user enters an acting rate now, and that's not good.  I only want them to get an alert if they select an absence type but left a selection in the Acting Rate drop down, they can't enter both.  Ideally, what I would I like to happen is if the user has entered an Acting Rate and then enters an Absence Type, the alert will pop up and the Acting Rate will be removed and the Absence Type will remain.  If it's too cumbersome I might not add it.  This is what I entered in the custom calculation script ActingRateJob1Emp1 text:


if((event.value != "") && (this.getField("AbsencePayTypeJob1Emp1").valueAsString == this.getField ("AbsencePayTypeJob1Emp1").valueAsString)){ app.alert("Do not enter acting rate with absence time",3); event.value = "";}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

That's because you're using the wrong event. This should be a validation script, not a calculation one.

And you should replace this part of it:

event.value = ";

with:

event.rc = false;

 

You're still comparing the value of AbsencePayTypeJob1Emp1 to itself, though, which doesn't make sense...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 28, 2021 Jan 28, 2021

Copy link to clipboard

Copied

I'm still struggling and could use some help.  I've tried really hard but the closest I've been able to acheive what I need isn't exactly working how I need it to.  The alert comes up every time an Absence Type is selected, but what I need is the alert to only come up if an Acting Rate has been entered and then an Absence type has been selected.  If nothing has been selected in the Acting Rate dropdown I don't need the alert to come up if an Absence Type is selected.  I tried entering the following in run custom validation script in the Absence dropdown field:

event.value = this.getField("ActingRateJob1Emp1").valueAsString; {
app.alert("Remove Acting Rate before entering Absence Type")
event.rc = false;
}
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

LATEST

OMG!  I finally did it!!  Thank you so much for your help Try!!  That took me forever to figure out, I'm really not very good at this.  I put the following in the validation script in my Absence drop down field and it works just how I need it to now!  It's just so exciting, I have to tell someone!  Woot!!

if((event.value != "") && !(this.getField("ActingRateJob1Emp1").valueAsString==this.getField("ActingRateJob1Emp1").defaultValue)){ app.alert("Please remove Acting Rate",3); event.rc = false;}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines