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

Compare 4 fields to color a separate field

New Here ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

I need a field called Orders to turn Red if the field is empty and if any of the following four fields have a number in the field. CashSubTotal, AMEXSubTotal, Cash Total, AMEX Total. If the Orders field has data in it, the Orders field fillColor should have no color. 

 

I have tried many different If Else statements and can't figure this out.

 

Thanks for any help.

TOPICS
JavaScript

Views

813

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

Copy link to clipboard

Copied

Your description is not very clear. So the field's fill color should be red if that field itself is empty, and all the other fields? In other words, if any of those fields has a value (including that one itself), it should not be red?

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
New Here ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

This is an expense form.  If the person has an expense, they fill in the category for the expense.  The total of the expenses go into either CashSubtotal or AMEXSubtotal.  There is also a final total field of CashTotal and AmexTotal.  I do not need these fields colored.  When an expense is placed, all costs arer added in the CashSubtotal or AMEXSubtotal field. There are other costs that will populate the CashTotal and AMEXTotal fields. The individual is required to enter an order number for job costing in the ORDERS field. This field is not always filled out and that is the field I want RED if and of the four fields I mentioned above have an entry and the Order field is left blank.

 

Hope this gives a better explanation.

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

Copy link to clipboard

Copied

Sorry, I can't follow your last sentence:

> This field is not always filled out and that is the field I want RED if and of the four fields I mentioned above have an entry and the Order field is left blank.

 

Did you mean to write "if any of the four fields"? That would make a bit more 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
New Here ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Yes, I would like the field to turn red on any of the 4 other fields having an entry.

Sent from Mail for Windows 10

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 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

You can use this code as the field's custom calculation script, then:

 

var fields = ["CashSubTotal", "AMEXSubTotal", "Cash Total", "AMEX Total"];
var myFillColor = color.transparent;
for (var i in fields) {
	var f = this.getField(fields[i]);
	if (f.valueAsString!="") myFillColor = color.red;
}
event.target.fillColor = myFillColor;

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
New Here ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

LATEST

I entered the code but the Orders field does not change color.

 

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