function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nerv123Nerv123 

How to display a message based on a condition?

I have a situation wherein if a field, X in Leads has a value >= 5, then a message has to be displayed automatically, without clicking on a button or link.
This is a simple message, not an error, nor related to a field update/email.
 
Please help.
 
Thanks!
TCAdminTCAdmin
Hello Nerv123,
 
You can create an inline s-control that holds an alert() statement within an if statement. That would be the easiest way to display something on the screen in a popup. If you only want it displayed in a field you can do the same with an inline s-control.
jrotensteinjrotenstein
I presume that you wish to display this field on a Lead screen, when that particular Lead has the field > 5?

Try creating an S-Control like this, then putting it in the Lead page layout:
Code:
<script>
if ({!Lead.somefield} > 5)
{
  document.write('<font size=4 color=red>Warning!</font>');
}
</script>

 Format according to taste, perhaps even with a colored background.

Nerv123Nerv123

How do I create an inline Scontrol? My very limited understanding says that Scontrols are links or buttons -- in this case, it has to be an automatic deduction when the field value is greater than 5....I hope I am making sense.

Please help!

TCAdminTCAdmin
Hello Nerv123,

You can place an s-control on a page layout as you can other fields. This results in it being ran every time the record is viewed. Once you add it to the page layout you will want to double-click on it and determine if you want to display the label and what height you would like to use. There are a couple solutions on the boards that will allow it to determine the height it needs automatically but if you are only displaying a specific message it isn't something that you should need to use.
Nerv123Nerv123

Chris and John,

 

Thanks So Much!

I learnt something new today and it works!!!

BUT, the minute I add another condition to the if clause it does not work, like

<script>
if
AND(({!Lead.Check } >= 5) , (ISPICKVAL(Lead.Status, "PreQualify-D")}

{
  document.write('<font size=4 color=red>Warning!</font>');
}
//}
</script>

 
I also tried with the && condition with no success either....
 
Thanks for helping this newbie!
jrotensteinjrotenstein
This is JavaScript, not a formula function, so use:

Code:
<script>
if ({!Lead.Check} >= 5 && '{!Lead.Check }' == 'PreQualify-D')
{
  document.write('<font size=4 color=red>Warning!</font>');
}
//}
</script>

 
Be sure to put any inserted string fields in quotes, eg '{!Lead.Check }'
Nerv123Nerv123

Thank You So Much, John....I was missing the quotes around the string field, did not know that!

 

jrotensteinjrotenstein
Yes, it's hard to notice when you look at the code. The important thing to realise is that the stuff {in braces} gets substituted.

So:
 if ({!Lead.Check} >= 5 && '{!Lead.Check }' == 'PreQualify-D')
Becomes:
 if (6 >= 5 && 'Evaluation' == 'PreQualify-D')
Gets me every time!