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

THE VALUE OF TWO DIFFERENT DROPDOWN FIELDS TO DETERMINE WHAT GETS DISPLAYED IN TWO DIFFERENT FIELDS

Participant ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

The first dropdown is called "Key_Distributors" with the following list (-SELECT-, PAT-SONNY NIGERIA ENTERPRISES, EVANS MAC BUSINESS VENTURES LTD, HAYAT INTERGRATED SERVICES LIMITED (Abuja), ALHAJA KOLAWOLE NIGERIA ENTERPRISES, DAM-LIZZY VENTURES, HAPPY PLACE INTERNATIONAL,)
The second dropdown is called "Category" with the following list (-SELECT-, Foods, Household, Nastrade)
The two fields to display values dependant on the the two dropdown fields are called "Credit_Limit & Customer_Code"
for example If PAT-SONNY NIGERIA ENTERPRISES and Foods are select from the dropdowns, below is what should be displayed.
"Credit_Limit" field to display 1000, "Customer_Code" field to display 100222
If PAT-SONNY NIGERIA ENTERPRISES and Nastrade are select from the dropdowns, below is what should be displayed.
"Credit_Limit" field to display 2000, "Customer_Code" field to display 15022
If EVANS MAC BUSINESS VENTURES LTD and Household are select from the dropdowns, below is what should be displayed
"Credit_Limit" field to display 4000, "Customer_Code" field to display 110033.
similarly with the other dropdown list.
I hope this could be done.
thanks in anticiption for a quick response

TOPICS
PDF forms

Views

2.1K

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

correct answers 1 Correct answer

Community Expert , Jun 04, 2022 Jun 04, 2022

Here's the basic syntax to use (for the Credit_Limit field, in this case):

 

var v1 = this.getField("Key_Distributors").valueAsString;
var v2 = this.getField("Category").valueAsString;

if (v1=="PAT-SONNY NIGERIA ENTERPRISES" && v2=="Foods") event.value = 1000;
else if (v1=="PAT-SONNY NIGERIA ENTERPRISES" && v2=="Nastrade") event.value = 2000;
// etc.
else event.value = "";

 

Add all the values where it says // etc., using the same format, and then adjust the script for the other field, too.

Kee

...

Votes

Translate

Translate
Community Expert ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

Here's the basic syntax to use (for the Credit_Limit field, in this case):

 

var v1 = this.getField("Key_Distributors").valueAsString;
var v2 = this.getField("Category").valueAsString;

if (v1=="PAT-SONNY NIGERIA ENTERPRISES" && v2=="Foods") event.value = 1000;
else if (v1=="PAT-SONNY NIGERIA ENTERPRISES" && v2=="Nastrade") event.value = 2000;
// etc.
else event.value = "";

 

Add all the values where it says // etc., using the same format, and then adjust the script for the other field, too.

Keep in mind, though, that JS is case-sensitive, so if the value is "FOODS" then you must write it like that in your code, as "Foods" won't work, and vice versa.

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 ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

i adjusted the script as this:

var v1 = this.getField("Key_Distributors").valueAsString;
var v2 = this.getField("Category").valueAsString;

if (v1=="PAT-SONNY NIGERIA ENTERPRISES" && v2=="Foods") event.value = 1000;
else if (v1=="PAT-SONNY NIGERIA ENTERPRISES" && v2=="Household") event.value = 2000;
else if (v1=="PAT-SONNY NIGERIA ENTERPRISES" && v2=="Nastrade") event.value = 3000;

if (v1=="EVANS MAC BUSINESS VENTURES LTD" && v2=="Foods") event.value = 4000;
else if (v1=="EVANS MAC BUSINESS VENTURES LTD" && v2=="Household") event.value = 6000;
else if (v1=="EVANS MAC BUSINESS VENTURES LTD" && v2=="Nastrade") event.value = 5000;

if (v1=="HAYAT INTERGRATED SERVICES LIMITED (Abuja)" && v2=="Foods") event.value = 4000;
else if (v1=="HAYAT INTERGRATED SERVICES LIMITED (Abuja)" && v2=="Household") event.value = 4000;
else if (v1=="HAYAT INTERGRATED SERVICES LIMITED (Abuja)" && v2=="Nastrade") event.value = 4000;

if (v1=="ALHAJA KOLAWOLE NIGERIA ENTERPRISES" && v2=="Foods") event.value = 1000;
else if (v1=="ALHAJA KOLAWOLE NIGERIA ENTERPRISES" && v2=="Household") event.value = 1000;
else if (v1=="ALHAJA KOLAWOLE NIGERIA ENTERPRISES" && v2=="Nastrade") event.value = 1000;

if (v1=="DAM-LIZZY VENTURES" && v2=="Foods") event.value = 6000;
else if (v1=="DAM-LIZZY VENTURES" && v2=="Household") event.value = 7000;
else if (v1=="DAM-LIZZY VENTURES" && v2=="Nastrade") event.value = 3000;

if (v1=="HAPPY PLACE INTERNATIONAL" && v2=="Foods") event.value = 6000;
else if (v1=="HAPPY PLACE INTERNATIONAL" && v2=="Household") event.value = 7000;
else if (v1=="HAPPY PLACE INTERNATIONAL" && v2=="Nastrade") event.value = 3000;
else event.value = "";

and placed it the "Credit_Limit" custom calculation script but nothing was displayed. i guess i didnt adjust it properly. pls help look at it again for corrections.

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 ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

It will only calculate last 'if' condition for 'HAPPY PLACE INTERNATIONAL'.

Put 'else if' on all condition, leave only first one 'if'.

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 ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

I Really feel at home. Thanks to you all for your help. 

My rain drops are gradually becoming an ocean in the work place. bosses and colleagues are feeling safe over the path i'm leeding them through. and its all because of you guys.

Thanks a lot.

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 ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

Nesa's comment is correct. Also, you can also simplify parts of your code. For example this part:

if (v1=="HAYAT INTERGRATED SERVICES LIMITED (Abuja)" && v2!="Foods") event.value = 4000;
else if (v1=="HAYAT INTERGRATED SERVICES LIMITED (Abuja)" && v2=="Household") event.value = 4000;
else if (v1=="HAYAT INTERGRATED SERVICES LIMITED (Abuja)" && v2=="Nastrade") event.value = 4000;

 

In this case the second value doesn't matter, since it will always be 4000, so you just want to make sure it's not the default value. So you can replace that whole part with just this:

 

else if (v1=="HAYAT INTERGRATED SERVICES LIMITED (Abuja)" && v2!="-SELECT-") event.value = 4000;

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 ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

I just tried that. Worked perfectly.

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 ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

I have another similar request.
Let's say I am running a promo on these products from a dropdown ("CORNFLAKES ORIGINAL 36*35G", "ACTION 10*1KG", "ASSORTED CREAM BISCUIT 48*44G", "FROSTED FLAKES 10*350G",)
With this promo, when you buy 10 cartons upward; you get 1 free carton for every 10 cartons within a timeframe.
for example, I am to run this promo from 07-06-2022 to 05-07-2022, I want when a buyer selects any of the above lists of product and type in 99 or any figure on the "QTY" field, it should calculate and display the number of ctns you get from dividing the "QTY" value he imputed by 10 with a suffix of "free" on a field labeled "TVI". And when the promo deadline reaches, it should display N/A. This means the "QTY" & those product lists from the "Products" dropdown field would always be looking at the "Current_Date" field to determine what gets displayed on the "TVI" field.

I really hope this can be done.

Thanks a lot.

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 ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

It's possible, but making it dependent on a date is tricky. Should it rely on the computer date, or on a date entered into the form? If the former, the user will just be able to change the date on their computer to get the free items... Also, what if they fill it in during this period, but send it to you afterwards? 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 ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

I want it to depend on the computer date. i thought of those possibilities. i am to as well use the date the form was sent back to my mail to justify if the person qualifies for it. thus, if the person changes the date on his computer, i'll still look at when he submits it.

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

Try this code, as the custom calculation script of "TVI":

 

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

var qty = Number(this.getField("QTY").valueAsString);
if (now.getTime()<startDate.getTime() || now.getTime()>endDate.getTime()) 
	event.value = "N/A";
else if (qty>10) 
	event.value = Math.floor(qty/10) + " free";

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

Okey. 

Thanks a lot.

from the code I noticed my mistake in expression. what I didn't mention is the dropdown has other lists of products from the dropdown. the ones I mentioned are just a few from the whole list of dropdowns. the request from the buyer might include other products. the display on free cartons should be based on the ones the promo is on. e.g., my list of products might be from A - Z but the promo is on B, C, & D

Thanks for everything thus far.

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

Sorry, I don't quite follow what you mean... It would be easier to help you if I could see the actual file.

Could you share it, perhaps?

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

I have attached a rough version of it. i just made provision for the TVI fields on top of the table.

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

I think I understand. You can do it like this, then:

 

var startDateString =  "07-06-2022";
var endDateString =  "05-07-2022";
var discountedProducts = ["ASSORTED CREAM BISCUIT 36*100G", "CORNFLAKES ORIGINAL 10*350G", "DELIGHT COOKIES 16*120G"]; // replace with actual product names

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.0").valueAsString);
var product = this.getField("Products.0").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";
}

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

perfect!!!!!

This is exactly what I wanted.

Thanks a million times

Do I have to repeat the script for all the rows?

just in case he selects the product in a different row. I'm asking because I would be making a column for the TVI withing the table.

 

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

It's possible to convert it into a generic function and call it from each field, passing the row number as an input parameter, assuming the list of discounted products is the same for all rows.

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

That would be perfect for me. pls, show me how.

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

Actually, you don't even need to pass that parameter. Place this code as a doc-level script:

 

function calcTVI() {
	var rowNumber = event.target.name.replace("TVI.", "");
	var startDateString =  "07-06-2022";
	var endDateString =  "05-07-2022";
	var discountedProducts = ["ASSORTED CREAM BISCUIT 36*100G", "CORNFLAKES ORIGINAL 10*350G", "DELIGHT COOKIES 16*120G"]; // replace with actual product names

	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";
	}
}

 

And then just call it from the fields, like this:

 

calcTVI();

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

I really don't know how this works but when you say place this calcTVI();. is it in the custom cal. field?

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

Correct.

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 ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

I'll do just that.

I sincerely appreciate all the time and suggestions you've given me thus far. I really learned a lot.

Thanks again

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

Copy link to clipboard

Copied

I need a little help with the attached form.

Now that we are trying to put the form to use, we realize the discount calculation base on the radio button click is not working properly unless you click it more than once before it does the discount calculation. and when you select another product it would not calculate the discount until you click it again. 

Thanks in anticipation.

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

Copy link to clipboard

Copied

You need to fix the fields calculation order, so that the Discount field is calculated after the Amount fields and Total Amount.

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

Copy link to clipboard

Copied

I just arranged it and cleared the form. I still get the same result.

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