add multiple child records based on parent criteria with formula url button

  • 1
  • 2
  • Question
  • Updated 2 years ago
  • Answered

I'm working on setting up a project management application.  I have a quotes/projects (parent) and tasks table (child).  Currently, when a record is opened on the quotes/projects table it starts off with a <quote opened> status and I have a "submit quote" formula url button that is set up to change the status to <quote submitted> and add a quote task to drive the quoting process.  

The workflow is working great for the quoting process.  Once the status is changed to <quote approved>, I have a "submit project" formula url button set up to change the status to <project submitted>, but I would also like to have this same button add multiple task records based on criteria in the parent record (i.e. project category and type).     

I've looked at the copy master and detail record wizard, but I don't believe this will work for me since I already have the master record created and I don't need to copy a new one... I just need to add the task records at this point.  

I was able to figure out how to add the quote task record with the submit quote button, but this did not involve any criteria validation or adding multiple child records so this is where I am stuck.

Any guidance is appreciated!


EDIT - I was able to use the copy master and detail record wizard to add the task records without creating a new master record.  Now where I am stuck is I need to combine the adding of the task records with the code from my "submit project" button that changes the quote/project status to <project submitted>... rather than my users having to click two separate buttons.  I thought maybe I could just add the code from the two buttons in to one, but that didn't work.  Is this possible??

Photo of Jennifer

Jennifer

  • 10 Points

Posted 4 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 65,320 Points 50k badge 2x thumb
Yes this is possible but I am traveling now and may not be able to answer until the weekend. I will respond then if no one else chimes in with an answer.
Photo of Daniel A

Daniel A

  • 40 Points
Hello Jennifer,


So while you don't have to copy the master record, you can use the Import record button to import those child tasks needed for the project parent record. However you will need to setup task template records to be imported each time you use the button.


http://www.quickbase.com/user-assistance/Default.html#create_copy_import_button.html


Here are similar discussions with additional detail options that can help:
https://quickbase-community.intuit.com/questions/796553?_ans=1&_pos=2&_src=sapi&_tot=4860&from=sapi&...=

https://quickbase-community.intuit.com/questions/59190?_ans=1&_pos=3&_src=sapi&_tot=6945&from=sapi&t...=

If you are still having issues, we recommend to put in a support ticket for further assistance.

Thank you,
QuickBase Customer Care
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,320 Points 50k badge 2x thumb
Jennifer,
I'm back now.  If you do want to combine this into one button, you can contact me off lune via the information in my Profile.  Basically, to be able to string together multiple actions, you will need to use form of the API to do the importing, as opposed to making a button using the wizard helper.

So you would have three formula variables.

var text URLONE = ( and paste in your existing URL which will edit the record to change its status);

var text URLTWO = ( and you would use the API format of the Copy Master detail.  Its described in the HELP searching on API with the filter set to "on line help"

var text URLTHREE = URLRoor() & "db/" & dbid() & "?a=dr&rid=" & [Record ID#];

Then string them together with
$URLONE
& "&rdr=" & URLEncode($URLTWO)
& URLEncode("&rdr=" & URLEncode($URLTHREE))
Photo of Jennifer

Jennifer

  • 10 Points
Thanks for the response, Mark!  The API format for the copy master detail help topic was a bit over my head, but I was able to figure out how to make this work by using the EditRecord and AddRecord API format.  I've created 25 different URL formula buttons (one for each product type) and I'm controlling which button the user will see using dynamic form rules.  Maybe not the easiest way to accomplish this, but it works!
Photo of Jennifer

Jennifer

  • 10 Points
In applying the dynamic form rules I've run in to an issue where I've exceeded the maximum number of derived fields... UGH!  Any idea on how to get around this?  As I mentioned, I have 25 formula URL buttons (one for each product type - each one adds the appropriate task records depending on the product type).  The only thing I can think of would be to somehow combine these all in to one button, but I don't have any idea on where to begin with that or if it would even be possible... is it even possible to combine an IF statement with the AddRecord and EditRecord API??
Photo of Ben L

Ben L

  • 120 Points 100 badge 2x thumb
This string didn't seem to answer my question, but it's close I think. Basically, what i'm trying to do is create one formula URL button that will process multiple copy master child functions, based on a multi-select field. I currently have 13 copy/master child buttons based on templates that generate tasks when pressed. I want to create a multi-select field where the user can select one of more options to determine which copy master/child function runs, then one button that runs the copy master/child functions based on the selections in the multi-select field. Any suggestions are helpful, thanks!
Photo of Jennifer

Jennifer

  • 10 Points
If I'm understanding you correctly, are you able to use dynamic form rules based on your multi-select field to hide/show only the button that meets the form rule criteria?  I had 25 different buttons, but I am only displaying 1 button on the form for the user to click based on the "Project Type" chosen.  I have set up each button with the same label "Submit Project" so that the user doesn't even know any difference... as long as they choose the correct Project Type then the correct functions run and the correct records are added to the child table.  Hope this helps!
Photo of Ben L

Ben L

  • 120 Points 100 badge 2x thumb
Thanks for the quick response! I had thought about that option as well, but there is the potential to select more than one "Project type", so that would require the clicking of more than one button. I'm trying to simplify the process for the end user by consolidating all the individual buttons into one. Also, I generally try to keep the number of form rules in play to a minimum. If there isn't a way, without creating a customer JS page, I'll definitely resort to this. Thanks!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,320 Points 50k badge 2x thumb
Benjamin,

This is not tested but might work

I got this code from Xavier fan, another QSP who is active on this forum

The URL would look something like this:

var text Choice = ToText([My Multi-Select field];
var text DummyURL = and insert code to edit a dummy checkbox field to be = 1;
var text CMDOne = and insert the URL that does the CopyMasterDetail number One;
var text CMDTwo = and insert the URL that does the  CopyMasterDetail number Two'
var text CMDThirteen = and insert the URL that does the  CopyMasterDetail number Thirteen;

var text URLOne = if(Contains($Choice,"Cats"), $CMDOne, $DummyURL);
var text URLOne = if(Contains($Choice,"Dogs"), $CMDTwo, $DummyURL);
...
var text URLThirteen = if(Contains($Choice,"Parrots"), $CMDThirteen,  $DummyURL);



"javascript:" &

"$.get('" &

$URLOne &

"').then(function(){" &

"$.get('" &

$URLTwo &

"').then(function(){" &

"$.get('" &

$URLThree &


etc
 and then end it with the code below



"')" &

"})" &

"});"

& "void(0);"
Photo of Clayton Rountree

Clayton Rountree

  • 264 Points 250 badge 2x thumb
how would I add a redirect to the end of this? instead of void, I want to redirect to another location
Photo of Ben L

Ben L

  • 120 Points 100 badge 2x thumb
Thanks for the feedback and suggestion. That's a bit beyond my abilities with JS. I'll see if a co-worker can help further.