Forum Discussion

IvanWeiss's avatar
IvanWeiss
Qrew Captain
4 years ago

Cleaning up javascript in formula URL's

Hi everyone,

I have several formula URL's with the following code in them.  Even though I know technically they can stay, I just cannot add in the future I am trying to comply with the new policies and get the script out of there....  The intent of the first javascript call is to popup an alert if a field is not completed and if so stop executing.  The second javascript call is to alert the user the code did run so they know.   What is the best way to implement this under the new guidelines?

Thanks in advance for your help!!!!

//Button for the RFI log to review a construction admin request on the particular button. It will first check to see if the construction admin was selected and if not display a message. Otherwise it will create a task for the Construction Admin Reviewer

//Check if Construction Administration Reviewer was populated
If(IsNull([Project - Construction Administration Reviewer]),
//If not pop up a dialogue prompting the user
"javascript: alert ('You must set the Construction Administration Reviewer on the Project first. Request was not submitted.')",
//If it was populated create URL to assign a task to that person to perform the review
var text URL = URLRoot() & "db/" & [_DBID_TASKS] & "?a=API_AddRecord" &
"&_fid_21=" & URLEncode ([Project Number]) &
"&apptoken=xxxxxxxx" &
"&_fid_6=" & URLEncode("Review RFI for Project ") & URLEncode([Project - Name]) & ": " & URLEncode([Company - Name]) &
"&_fid_8=" & URLEncode(Today()) &
"&_fid_9=" & URLEncode(WeekdayAdd(Today(),3)) &
"&_fid_23=" & URLEncode("Construction Administration") &
"&_fid_24=" & URLEncode("Assigned") &
"&_fid_28=" & URLEncode("Not Applicable") &
"&_fid_52=" & URLEncode([Project - Construction Administration Reviewer]) &
"&_fid_69=" & URLEncode([Project Coordinator]) &
"&z=" & Rurl();
//Dialogue to confirm the request was submitted
"javascript:" &"$.get('" & $URL & "',function(){" &"location.reload(true);" &"});" & "void(0);alert('Request Created');"
)

------------------------------
Ivan Weiss
------------------------------
  • Hi Ivan,

    If you are looking for a way to assure that certain data is entered before a record can be saved and to call it out for your user Custom Data rules allow you to build a rule in your tables using the formula language that will prevent a use from saving a record without filling in the required fields and you can write your own error messages to help your users. While that doesn't give you the pop up it will prevent the save and prompt your user to fill in the needed information. Then if you needed to create a new record you could use Pipelines to trigger its creation upon the save. 

    Alternatively, while unsanitized Javascript is being locked down inside of formula fields in August it can still be used in code pages in the future. Using a code page and our recent pop up option in formula url fields you may be able to recreate this workflow using a code page. If you haven't used them before you can learn more about code pages here and also see some examples of code page solutions in our code page sample app. It is also possible someone else here in the Community might be doing something similar already using code pages and Javascript. I hope that information is helpful Ivan.

    ------------------------------
    Evan Martinez
    Community Marketing Manager
    Quickbase
    ------------------------------