app.alert with oCK struggle

New Here ,
Jun 14, 2019

Copy link to clipboard

Copied

I am incredibly green with JS, maybe a week into learning; please ELIM5.  I have created a form that will highlight a field based on its value.  The issue I am having is during validation.  I am attempting to populate a window to remind the end user to check for restrictions.  I have read the tutorial and created a code based on the information provided; however, I am still unable to get it to run correctly.  I have provided both versions for reference.  The first code populates an alert anytime the cell is changed, and I understand why based on the coding.  The following code is my attempt at only having the warning populate based on fill color.  Both versions are forcing the alert incorrectly or not at all.  I previously had the app.alert in the format code (provided as struck in the first "if" case) but was unable to get the oCK to operate, which is a must for the end user.  Thank you in advance for any assistance!

Format code:

var mf = (event.value);

if (mf =="1.1" || mf =="1.1A" || mf =="1.1B" || mf =="1.1C" || mf =="1.1D" || mf =="1.1E" || mf =="1.1F" || mf =="1.1G" || mf =="1.1H" || mf =="1.1J" || mf =="1.1K" || mf =="1.1L" || mf =="1.1N" || mf =="1.1S")

{event.target.fillColor = color.red;

app.alert("super important message!", 1, 0, "Title", oCK );

event.rc = false;

}else{

if (mf == second case)

{event.target.fillColor = color.red;

}else{

if (mf == third case)

{event.target.fillColor = ["RGB",1,.35,0];

}else{

if (mf == fourth case)

{event.target.fillColor = color.yellow;

}else{

//if less restrictive or blank

if (mf >= 2 || mf == "")

event.target.fillColor = ["T"];}

}}}

Validation code:

     First attempt:

event.rc = !mf;

if(!event.rc && !this.hideWarning1){

var oCK = {bAfterValue:false};

app.alert({cMsg:"super important message!", nIcon:1, nType:0, cTitle:"amazing title", oCheckbox:oCK});

hideWarning1 = oCK.bAfterValue;

}

     Second attempt:

event.rc = event.target.fillColor;

if(!event.rc !== ["T"] && !this.hideWarning1){

var oCK = {bAfterValue:false};

app.alert({cMsg:"super important message!", nIcon:1, nType:0, cTitle:"amazing title", oCheckbox:oCK});

hideWarning1 = oCK.bAfterValue;

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

96

Likes

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

app.alert with oCK struggle

New Here ,
Jun 14, 2019

Copy link to clipboard

Copied

I am incredibly green with JS, maybe a week into learning; please ELIM5.  I have created a form that will highlight a field based on its value.  The issue I am having is during validation.  I am attempting to populate a window to remind the end user to check for restrictions.  I have read the tutorial and created a code based on the information provided; however, I am still unable to get it to run correctly.  I have provided both versions for reference.  The first code populates an alert anytime the cell is changed, and I understand why based on the coding.  The following code is my attempt at only having the warning populate based on fill color.  Both versions are forcing the alert incorrectly or not at all.  I previously had the app.alert in the format code (provided as struck in the first "if" case) but was unable to get the oCK to operate, which is a must for the end user.  Thank you in advance for any assistance!

Format code:

var mf = (event.value);

if (mf =="1.1" || mf =="1.1A" || mf =="1.1B" || mf =="1.1C" || mf =="1.1D" || mf =="1.1E" || mf =="1.1F" || mf =="1.1G" || mf =="1.1H" || mf =="1.1J" || mf =="1.1K" || mf =="1.1L" || mf =="1.1N" || mf =="1.1S")

{event.target.fillColor = color.red;

app.alert("super important message!", 1, 0, "Title", oCK );

event.rc = false;

}else{

if (mf == second case)

{event.target.fillColor = color.red;

}else{

if (mf == third case)

{event.target.fillColor = ["RGB",1,.35,0];

}else{

if (mf == fourth case)

{event.target.fillColor = color.yellow;

}else{

//if less restrictive or blank

if (mf >= 2 || mf == "")

event.target.fillColor = ["T"];}

}}}

Validation code:

     First attempt:

event.rc = !mf;

if(!event.rc && !this.hideWarning1){

var oCK = {bAfterValue:false};

app.alert({cMsg:"super important message!", nIcon:1, nType:0, cTitle:"amazing title", oCheckbox:oCK});

hideWarning1 = oCK.bAfterValue;

}

     Second attempt:

event.rc = event.target.fillColor;

if(!event.rc !== ["T"] && !this.hideWarning1){

var oCK = {bAfterValue:false};

app.alert({cMsg:"super important message!", nIcon:1, nType:0, cTitle:"amazing title", oCheckbox:oCK});

hideWarning1 = oCK.bAfterValue;

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

97

Likes

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
Jun 14, 2019 0
Most Valuable Participant ,
Jun 14, 2019

Copy link to clipboard

Copied

Please tell us in detail what you expect to happen from your code, and what actually does happen. We don't know what you intended, only what you wrote. Also the contents of the JavaScript console. Also the type of field to which these are attached. Thanks.

Likes

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
Reply
Loading...
Jun 14, 2019 0
Adobe Community Professional ,
Jun 14, 2019

Copy link to clipboard

Copied

Ok, so you read the article here:

https://acrobatusers.com/tutorials/popup_windows_part1

But there is a potential error in the code in the article and in your code

First, "hideWarning1" is explicitly a document level variable. As such is always needs to be prefixed with the document object.

i.e.  "this.hideWarning1". Otherwise you can't be sure that it is being set properly.

Next, what are you trying to do with "event.rc"?  This is the return code for certain event operations and it is a Boolean.

Please do not respond with a long explanation. Make your response short and to the specific point.

Likes

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
Reply
Loading...
Jun 14, 2019 0
Adobe Community Professional ,
Jun 15, 2019

Copy link to clipboard

Copied

What is second case, third case, and fourth case?

Likes

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
Reply
Loading...
Jun 15, 2019 0