Hi Guys - would appreciate a little help here, I think I'm close but...
I am trying to write javascript to check whether several fields are null. Basically if ANY of the fields are populated then FinanceNotes should = "filled", if they are ALL null then it should be "empty".
The code I have so far is below however I am unsure what the correct syntax is to add all of the fields (FinanceImpact7, HealthSafetyImpact7 etc) - is it && or || etc?
if (ImpactsTable.Row1.FinanceImpact7.rawValue == null && ImpactsTable.Row2.HealthSafetyImpact7.rawValue == null && ImpactsTable.Row2.OpsBusinessImpact7.rawValue == null)
{
Subform2.ImpactsTable.Row1.FinanceNotes.rawValue = "empty";
}
else
{
Subform2.ImpactsTable.Row1.FinanceNotes.rawValue = "filled";
}
Cheers!!
Ellis
Solved! Go to Solution.
Views
Replies
Total Likes
You're using wrong SOM expressions, because you're pointing to row2, that does not contain the desired field.
Subform2.ImpactsTable.Row1.FinanceNotes.rawValue = ImpactsTable.Row1.FinanceImpact7.isNull && ImpactsTable.Row2.HealthSafetyImpact7.isNull && ImpactsTable.Row2.OpsBusinessImpact7.isNull && ImpactsTable.Row2.OpsCustomersImpact7.isNull && ImpactsTable.Row2.OpsEmployeesImpact7.isNull && ImpactsTable.Row2.ReputationHeader7.isNull && ImpactsTable.Row2.ReputationStakeholders7.isNull ? "empty" : "filled";
Change it into:
ImpactsTable.Row1.FinanceNotes.rawValue = ImpactsTable.Row1.FinanceImpact7.isNull && ImpactsTable.Row2.HealthSafetyImpact7.isNull && ImpactsTable.Row3.OpsBusinessImpact7.isNull && ImpactsTable.Row4.OpsCustomersImpact7.isNull && ImpactsTable.Row5.OpsEmployeesImpact7.isNull && ImpactsTable.Row6.ReputationHeader7.isNull && ImpactsTable.Row7.ReputationStakeholders7.isNull ? "empty" : "filled";
Views
Replies
Total Likes
Hi there,
the way you're code is working is, if each fields are null, give FinanceNotes "empty" value
if 1 field is different than null, give FinanceNotes "filled" value
Make sure that your syntax is good and each field names are well spelled, use the debugger to see if any error occurs and use the try catch statement to see in details the error..
Handling JavaScript Exceptions
I can see that in your if statement you specify ImpactsTable directly but in your code within the if clause is starting at Subform2.ImpactsTable.. make sure you use the right reference_syntax!
Hope this help!
Views
Replies
Total Likes
To test for null value you should use the operator === instead of ==
or you use the build-in method isNull.
Subform2.ImpactsTable.Row1.FinanceNotes.rawValue = ImpactsTable.Row1.FinanceImpact7.isNull && ImpactsTable.Row2.HealthSafetyImpact7.isNull && ImpactsTable.Row2.OpsBusinessImpact7.isNull ? "empty" : "filled";
Views
Replies
Total Likes
Thanks both for your ideas
Radzmar : I amended your code by adding some additional fields ( I have 7 in total ), I have used exactly the same syntax as your example yet it only seems to recognize that the first 2 fields are not null? Also the "empty" result does not seem to work?
Here is my amended code:
Subform2.ImpactsTable.Row1.FinanceNotes.rawValue = ImpactsTable.Row1.FinanceImpact7.isNull && ImpactsTable.Row2.HealthSafetyImpact7.isNull && ImpactsTable.Row2.OpsBusinessImpact7.isNull && ImpactsTable.Row2.OpsCustomersImpact7.isNull && ImpactsTable.Row2.OpsEmployeesImpact7.isNull && ImpactsTable.Row2.ReputationHeader7.isNull && ImpactsTable.Row2.ReputationStakeholders7.isNull ? "empty" : "filled";
And here is the pdf if it's easier?
https://www.dropbox.com/s/hrljvjyda8pd5ei/211%20For%20Forum.pdf?dl=0
Many many thanks !
Ellis
Views
Replies
Total Likes
You're using wrong SOM expressions, because you're pointing to row2, that does not contain the desired field.
Subform2.ImpactsTable.Row1.FinanceNotes.rawValue = ImpactsTable.Row1.FinanceImpact7.isNull && ImpactsTable.Row2.HealthSafetyImpact7.isNull && ImpactsTable.Row2.OpsBusinessImpact7.isNull && ImpactsTable.Row2.OpsCustomersImpact7.isNull && ImpactsTable.Row2.OpsEmployeesImpact7.isNull && ImpactsTable.Row2.ReputationHeader7.isNull && ImpactsTable.Row2.ReputationStakeholders7.isNull ? "empty" : "filled";
Change it into:
ImpactsTable.Row1.FinanceNotes.rawValue = ImpactsTable.Row1.FinanceImpact7.isNull && ImpactsTable.Row2.HealthSafetyImpact7.isNull && ImpactsTable.Row3.OpsBusinessImpact7.isNull && ImpactsTable.Row4.OpsCustomersImpact7.isNull && ImpactsTable.Row5.OpsEmployeesImpact7.isNull && ImpactsTable.Row6.ReputationHeader7.isNull && ImpactsTable.Row7.ReputationStakeholders7.isNull ? "empty" : "filled";
Views
Replies
Total Likes
Thanks radzmar!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies