How do I simplify this formula

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
My formula is working, but can I make the formula shorter or just simple.


var text URL = URLRoot() & "db/" & [_DBID_PROJECTS] & "?a=dr&rid=" & [Related Project - From Job] & "&dfid=17"& Rurl();
var text URLL = URLRoot() & "db/" & [_DBID_PROJECTS] & "?a=er&key="& [Related Project - From Job]&"&dfid=17";


If( [# of Projects - Building Forms]=1,
"<a style='text-decoration:none; font-weight:bold' class='Vibrant Success' href='" & $URL & "'>Open Form</a>",
"<a style='text-decoration:none; font-weight:bold' class='Vibrant Success' href='" & $URLL & "'> Send Form</a>"
)
Photo of Shontay

Shontay

  • 490 Points 250 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
The formula look very readable to me.  I would not try to make it shorter but more complicated.
Hi Shontay,

I'm not sure if this shortens the code, but it may make it a little more readable. By adding more variables it also makes it easier to update the code in the future (e.g. adding more lines of code or making adjustments).

Let me know if this helps!




var text urlRoot = URLRoot() & "db/";
var text projTbl = $urlRoot & [_DBID_PROJECTS];

var text openUrl = $projTbl & "?a=dr&rid=" & [Related Project - From Job] & "&dfid=17" & Rurl();
var text sendUrl = $projTbl & "?a=er&key="& [Related Project - From Job] & "&dfid=17";

var text open = "<a style='text-decoration:none; font-weight:bold' class='Vibrant Success' href='" & $openUrl & '>Open Form</a>";
var text close = "<a style='text-decoration:none; font-weight:bold' class='Vibrant Success' href='" & $sendUrl & "'> Send Form</a>";

If([# of Projects - Building Forms] = 1,
$open,
$close)
(Edited)