Forum Discussion

AlexKnox's avatar
AlexKnox
Qrew Member
4 years ago

If Function with Java Script

Hi all - I had a formula button working and then it doesnt seem to be working anymore and I cannot find the problem. 

I have a button that will create several child records once clicked. When the button is clicked, it will update a checkbox field which triggers an automation to copy records to the parent record. 

I like using a dialog box to let the end user know what happened. The dialog will either say tasks being created or tasks already created. This is done to avoid duplicate tasks being created. 

Right now, it is always saying that the tasks have already been created even the checkbox is not checked and there are zero child records 

Here is the code that I have used 

var text URL= URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
"&rid=" & URLEncode ([Record ID#]) &
"&_fid_104=Yes" &
"&apptoken=xxxxxxxxx";

var text RDR= URLRoot() & "db/" & Dbid() & "?a=dr" &
"&rid=" & URLEncode ([Record ID#]) &
"&apptoken=xxxxxxxxx";

If(ToText([Tasks Created]) = "No",

"javascript:" &"$.get('" & $URL & "',function(){" &"location.reload(true);" &"});" & "void(0); alert('Project Tasks are being created!');",

"javascript:" &"$.get('" & $RDR & "',function(){" &"location.reload(true);" &"});" & "void(0); alert('Project Tasks have already been created! Please check the task list at the bottom of the screen.');"

)

------------------------------
Alex Knox
------------------------------

1 Reply

  • AustinK's avatar
    AustinK
    Qrew Commander
    Is [Tasks Created] a checkbox? If so I would start with not converting it into text and just use True or False. If it isn't a checkbox, what is it and why is it being converted to text?

    If it is a checkbox then replace that line with this: If([Tasks Created] = False,

    I assume that is your problem here as the formula seems to be giving you the False entry no matter what. So I have to assume that [Tasks Created] is never equal to No.