Visual Status Dependant on Field Value being "At Least" as Expected
Hi All
I while ago I posed a question on this forum asking if anyone knew how to write a script that would have a 'Result' field show "Awaiting Input", "MATCH", or "MISMATCH", depending on whether the value entered into a in a 'Reported' field matched exactly the valued in an 'Expected' field.
The original post is here; Script for Dependant Visual Status - I had some fantastic help from George_Johnson and try67, to whom I owe a great deal of gratitude - may thanks once again!
I now have a need for a script that will do a very similar thing, but I need the visual status of my 'Result' field to show as "Awaiting Input", "Pass" or "Fail", depending on whether the value entered into the 'Reported' field is at least the value of what is in the 'Expected' field, rather than needing to be an exact match.
So, I have a read-only field called 'Expected-Sector-Count'. The expected value is "9,514,260"
I need the 'Result' field to show as "Pass" if the value entered into the 'Reported-Sector-Count' field is equal to, or greater than, 9,514,260
If the value entered into the 'Reported-Sector-Count' field is less than 9,514,260 then I need the 'Result' field to show as "Fail"
If the 'Reported-Sector-Count' field is blank, then the 'Result' field should show as "Awaiting Input".
Is it at all possible to modify the script below to achieve this? I'm assuming I would need to remove the comma separators from the values, but hopefully I can get them to show if I format the respective fields as 'Number' ?
I should mention this is not for profit and I would be extremely grateful if anyone could help! Many thanks in advance.
// Custom calculation JavaScript for text field
(function () {
// Get the field value, as a string, converted to uppercase
var sHash = getField("Acquired_Hash").valueAsString.toUpperCase();
if (sHash) { // Not blank
if (sHash === this.getField("Expected Hash").valueAsString.toUpperCase()) {
event.value = "Match";
event.target.textColor = color.green;
} else {
event.value = "MIS-MATCH";
event.target.textColor = color.red;
}
} else { // Input is blank
event.value = "Awaiting Input";
event.target.textColor = color.black;
}
})();
