Discussions

Expand all | Collapse all

API copy a record and change some fields

  • 1.  API copy a record and change some fields

    Posted 01-15-2020 15:06
    Hello QB Community,

    How do I use API to copy a record in the same table and change a couple of values in the newly created record.

    ------------------------------
    Howard Fu
    ------------------------------


  • 2.  RE: API copy a record and change some fields

    Posted 01-15-2020 15:35
    Are you copying a record that is already saved? or would this be like a "Save and New" button?

    ------------------------------
    Ryan Stanford
    ------------------------------



  • 3.  RE: API copy a record and change some fields

    Posted 01-15-2020 15:39
    I want to copy an existing record. The new record would have some values the same and some different.

    ------------------------------
    Howard Fu
    ------------------------------



  • 4.  RE: API copy a record and change some fields

    Posted 01-15-2020 15:36
    Did you want to be sitting on a record and pop up a duplicate of a record in Add mode waiting fir the user to complete certain fields, but with most fields carried forward, it did you actually want to create the record and land the user in the new record?

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 5.  RE: API copy a record and change some fields

    Posted 01-15-2020 15:42
    Hi Mark,

    I want to land the user in a newly created record where they don't have to make any changes.

    ------------------------------
    Howard Fu
    ------------------------------



  • 6.  RE: API copy a record and change some fields

    Posted 01-15-2020 15:55

    try this as a URL formula button  I'm just on my iPhone do post back if there are any syntax errors  



    URLRoot() & "db/" & Dbid()

    & "?act=API_AddRecord"
    & "&_fid_6=" & URLEncode ([Purchase Order])

    & "&_fid_17=" & [Qty]
    & "&_fid_10=" & [Related Priced Material]

    & "disprec=1"

    for each field ID you need a new line for your own sanity. 



    if the data being put into the field might have text with spaces of special characters, you need to URLEncode as above. 

    if here are fields of type User or date they need to converted to text

    Like

    & "&_fid_17=" & ToText(User field])

    the last line says to display the record after the click. 



    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 7.  RE: API copy a record and change some fields

    Posted 01-15-2020 18:30
    HI Mark,

    I tried the formula but I'm having some trouble when it comes to replacing the line below with my own information

    & "&_fid_6=" & URLEncode ([Purchase Order])

    Can you explain what this line is saying similar how you spell it out in your URL Buttons for Dummies app (very helpful by the way)?

    I have a multiple choice field called [Type] and the field ID is 8. The options are Price, Sample, and Purchase. I want the newly created record to say Purchase.

    I also have a text field called [Description] where users put in various information. I would like that field to be copied from the original to the new record.

    Can you please guide me in the right direction toward accomplishing those two things?



    ------------------------------
    Howard Fu
    ------------------------------



  • 8.  RE: API copy a record and change some fields

    Posted 01-15-2020 22:06
    The line should read

    & "&_fid_8=" & "Purchase"


    If the field ID for Description was 99 the line would read

    & "&_fid_99=" & URLEncode ([Description])


    That field will need the URLEncode, as the contents of that field are likely to include spaces or special characters.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 9.  RE: API copy a record and change some fields

    Posted 01-16-2020 19:47
    Hi Mark,

    I've entered all the fields I wanted to include in this button and everything works great so thank you for that. The last thing I need to fix is displaying the record. Right now it shows that there are no errors. I believe & "disprec=1" should display the record. Is there anything I need to change or try?

    ------------------------------
    Howard Fu
    ------------------------------



  • 10.  RE: API copy a record and change some fields

    Posted 01-17-2020 00:24
    I believe that the syntax is actually

    & "&disprec=1"

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 11.  RE: API copy a record and change some fields

    Posted 01-17-2020 14:07
    It worked!

    Thank you again Mark!

    ------------------------------
    Howard Fu
    ------------------------------