Skip to main content
Question

"Contains" formula with colorization

  • January 14, 2022
  • 0 replies
  • 62 views

Forum|alt.badge.img+11
This is what I am trying to do in a field called PRIME PT/UP DATE.COLOR

If [PRIME PT/UP DATE] contains Monday, (red button with M)
If [PRIME PT/UP DATE] contains Tuesday, (yellow button with T)...and so on

I am using this formula in another field...but, I do not know how to include the "If Contains":

var text ButtonColor = Case([Customer Initials],
"SM","#808000", // olive green
"KB20","#ffc966", // golden orange
"NVR","#ede7d3", // cream
"PUL","#003366", // navy blue
"TRU","#ff884d", // peach orange
"DWH","#004d99",
"GRH","#00cccc");



var text WordsColor = Case([Customer Initials],
"NVR","black",
"white");



// Begin button style
var text bgcolor = $ButtonColor;
var text txtcolor = $WordsColor;
var text style = "style=\"text-decoration: none; text-align: center; background:" & $bgcolor & "; width: 45px; border-radius: 50px; padding: 3px 5px; color: " & $txtcolor & "; display: inline-block; font: normal 500 16px/1 \"Calibri\", sans-serif; text-shadow: none;";
// End button style

var text URL = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Customer ID#];


"<a " & $style & " href=" & $URL & ">" & [Customer Initials] & "</a>"


------------------------------
BuildPro
------------------------------

Forum|alt.badge.img+11
  • Author
  • Registered
  • January 14, 2022
I have played around a bit.  Here is what I came up.  But, It is returning just the date instead of day of week "button

Here is the formula:
var text ButtonColor = If
(Contains(ToText([PRIME PT/UP DATE]),"Monday"),"#808000",
(Contains(ToText([PRIME PT/UP DATE]),"Tuesday")),"#ede7d3",
(Contains(ToText([PRIME PT/UP DATE]),"Wednesday")),"#ede7d3");



// Begin button style
var text bgcolor = $ButtonColor;

var text style = "style=\"text-decoration: none; text-align: center; background:" & $bgcolor & "; width: 100px; border-radius: 5px; padding: 3px 5px; color: " & "; display: inline-block; font: normal 700 24px/1 \"Calibri\", sans-serif; text-shadow: none;";
// End button style

"<div "& $style &">" & [PRIME PT/UP DATE] & "</div>"

//"<div " & $style & " " & [PRIME PT/UP DATE] & "</div>"

------------------------------
BuildPro
------------------------------