Forum Discussion

KellyBianchi's avatar
KellyBianchi
Qrew Assistant Captain
8 years ago

Check a box while opening a new record

I would like to mark the parent record assigned at the same time a new child record is created, in one scenario. So what can I add to the existing 'Add Record' formula to do that? 

URLRoot() & "db/" & [_DBID_LOCATIONS] & "?a=API_GenAddRecordForm&_fid_10=" & URLEncode ([Record ID#])& "&z=" 

-and-

In another scenario, I am looking to populate the Date/Time field while opening a new record. 
What can I add to my existing Time Stamp Button formula to do that?

var text URL = URLRoot() & "db/" & Dbid() &   "?act=API_EditRecord&rid=" &([Record ID#])
& "&_fid_29=" & Now();

"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});" & "void(0);
  • Fr the first one, I suggest that you consider an alternative approach.  If the "definition" of a parent record being assigned is that it has a child record, how about adding a summary field for the [# of children]

    Then make the checkbox field for [Parent Record assigned?] can be

    [# of children] >0

    or if you prefer to be needlessly verbose,

    IF([# of children] >0, true, false)

    As for the second question, are you saying that whenever the record is manually edited you want to set a date/time field to now()?  If that is the case, why not just use the built in [date modified] field  as it will be auto populated with the date/time of the last edit.
  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    If you are looking to edit the parent record then create a child record, you will want to use an

    API_EditRecord call with a RDR to the AddGenRecordFrom.

    Generally speaking it will look like this: 

    URLRoot() & "db/" & [_DBID_TASKS] & "?a=API_EditRecord&rid="&[Record ID#]&"&apptoken=xxxxxx&_fid_12="&URLEncode("true")&"&_fid_39="&URLEncode(User())&"&_fid_48="&URLEncode(Now())&"
    &rdr="&
    URLEncode([URL Add Time Entry])

    This one Edits the parent task (marks complete) and redirects to add a time entry.
  • KellyBianchi's avatar
    KellyBianchi
    Qrew Assistant Captain
    In both situations, I just want to execute an action based on the push of a formula button that already exists. The idea is just to streamline the workflow from 2 steps to 1.
    • MCFNeil's avatar
      MCFNeil
      Qrew Captain

      [Location Assigned]& "&rdr=" & URLEncode([Add Location])

      This might do it.

    • KellyBianchi's avatar
      KellyBianchi
      Qrew Assistant Captain
      This is what I'm getting: A formula may not contain a reference to itself directly or indirectly through another formula.
    • MCFNeil's avatar
      MCFNeil
      Qrew Captain
      Create a new field for the combined effort.