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

CALLING SCRIPT FROM DOCUMMENT LEVEL NOT RESPONDING

Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

I try to call the below scripts through the custom calculation field from document-level script with no luck.

what do I do?

function calcTVI() {
var rowNumber = event.target.name.replace("TVI.", "");
var startDateString = "01-08-2022";
var endDateString = "01-09-2022";
var discountedProducts = ["BONUS 6*900G (HDPE)", "BRYTEX WHITE 12*475G", "BRYTEX WHITE 6*900G", "BRYTEX (COLOURS) 12*475G", "BRYTEX (COLOURS) 6*900G"];

var startDate = util.scand("dd-mm-yyyy", startDateString);
var endDate = util.scand("dd-mm-yyyy", endDateString);
var now = new Date();
event.value = "";

var qty = Number(this.getField("QTY."+rowNumber).valueAsString);
var product = this.getField("Products."+rowNumber).valueAsString;
if (discountedProducts.indexOf(product)!=-1) {
if (now.getTime()<startDate.getTime() || now.getTime()>endDate.getTime())
event.value = "N/A";
else if (qty>10)
event.value = Math.floor(qty/10) + " Free Ctns";
}
}


function calcTVIFD() {
var rowNumber = event.target.name.replace("TVI.", "");
var startDateString = "01-07-2022";
var endDateString = "01-08-2022";
var discountedProducts = ["FANCY 48*50G"];

var startDate = util.scand("dd-mm-yyyy", startDateString);
var endDate = util.scand("dd-mm-yyyy", endDateString);
var now = new Date();
event.value = "";

var qty = Number(this.getField("QTY."+rowNumber).valueAsString);
var product = this.getField("Products."+rowNumber).valueAsString;
if (discountedProducts.indexOf(product)!=-1) {
if (now.getTime()<startDate.getTime() || now.getTime()>endDate.getTime())
event.value = "N/A";
else if (qty>20)
event.value = Math.floor(qty/20) + " Free Ctns";
}
}

 

below is the custom cal script

calcTVI();
calcTVIFD();

 

Thanks.

 

 

TOPICS
PDF forms

Views

1.9K

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Check the JavaScript console for errors.

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
Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

I did. below is the response.


ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:AcroForm:EmplEmail:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
ReferenceError: breaks is not defined
26:Field:Calculate
SyntaxError: missing ; before statement
1:Console:Exec
undefined

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
Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

I CHECKED

this is the message

14:Field: Calculate
ReferenceError: breaks are not defined
14:Field: Calculate

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Where does you use "breaks"?

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
Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

See attached

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Where does you use the exact word "breaks"?

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
Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

here is the file. sorry I can't remember me using breaks anywhere.

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Share a non-secured version of the file, please.

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
Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

HERE IT IS.

THANKS

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Calling both functions from the same field doesn't make sense. The results of the second one will always overwrite those of the first. Why did you split it into two functions?

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
Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

I thought it would work. the promo in most cases runs in Category FOODS & HOUSEHOLD with a different range of free products. FOODS CAN 10:1 HOUSEHOLD MIGHT BE 20:1

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

You have to combine the code to a single function, and then use multiple arrays for the various types of discounts. If the product is not in array1, check array2, etc.

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
Participant ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

I thought about that but have no idea how to combine them. pls guide/show me

Thanks

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

You also have extensive code running as custom calcuation script in all of those dropdown menus that get populated simultaneously with that function.

 

As soon as I selected one option from the main menu it took very long for the other dropdown fields to populate and almost crashed.

 

There are better methods to speed up heavy calculations like these, like incorporating custom keystroke scripts, javascript actions, or buttons.

 

 

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
Participant ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

I notice that too. The field guys complain about it all the time. please guide me on how to go about that. I am a novice.

Thanks

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

You can use something like this:

 

 

var discountedProducts1 = ["BONUS 6*900G (HDPE)", "BRYTEX WHITE 12*475G", "BRYTEX WHITE 6*900G", "BRYTEX (COLOURS) 12*475G", "BRYTEX (COLOURS) 6*900G"];
var discountedProducts2 = ["FANCY 48*50G"];
var isNA = (now.getTime()<startDate.getTime() || now.getTime()>endDate.getTime());

if (discountedProducts1.indexOf(product)!=-1) {
	if (isNA) event.value = "N/A";
	else if (qty>10) event.value = Math.floor(qty/10) + " Free Ctns";
} else 	if (discountedProducts2.indexOf(product)!=-1) {
	if (isNA) event.value = "N/A";
	else if (qty>20) event.value = Math.floor(qty/20) + " Free Ctns";
} // etc.


 

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
Participant ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

thanks a lot.

should I place the script at the document level or should I put it somewhere else?

thanks

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
Participant ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

And one more thing. The start and end date in most instances are not the same for FOODS & HOUSEHOLD. I notice the script has only one start and end date.

that is why I did what I did initially.

Thanks.

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 ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

- Doc-level is better.

- I thought that might be the case. In that case you would need to use separate date values for each array, and won't be able to use a single variable, like I did with isNA.

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
Participant ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

how do I now use separate date values for each array? I mean how the script should be.

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 ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

Have you ever tried it? We're not really here to write your code for you, but to guide you in doing so.

 

If you're interested in hiring someone to do it for you, contact me privately to discuss it further.

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
Participant ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

Okay. that sounds great to me.

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
Participant ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

can it be customized to work with mobile phones or pads?

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 ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

LATEST

Very unlikely, no. The only mobile app where it might work is PDF Expert by Readdle for iOS devices.

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