Discussions

 View Only
  • 1.  Single Button to Save & Keep Working Before Editing a Record (ex. change a checkbox)?

    Posted 11-24-2020 11:53
    I am looking to combine two buttons I've found solutions to via this community (thank you!!), but I am unsure how/if it's possible. 

    Button 1: "Save & Keep Working" Rich Text Field
    "<div class='Vibrant Success' onclick=$('#footerSaveAndKeepWorkingMenuOption').click();>Generate Document</div>"

    Button 2: "Change a checkbox" URL Formula Field
    var text Token ="TOKEN";
    var bool NewValue = not [checkboxfield];
    var text URL = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&apptoken="& $Token &"&rid="& [Record ID# #] & "&_fid_checkboxfield=" & URLEncode($NewValue) & "&disprec=1";

    "javascript:" &
    "$.get('" &
    $URL &
    "',function(){" &
    "location.reload(true);" &
    "});" & "void(0);"

    Objective:
    Clicking a single button that saves any changes to a record first, then changes a checkbox on the same record that triggers a pipeline, automation and/or webhook to run.

    So from a flow standpoint, I want a user to be able to click a button to manually trigger an action, as sometimes the automation/pipeline is not necessary every time certain fields change (ie changing a date does not mean that the document needs to be created right then), but it is necessary that any changes to the record are saved before triggering that action (ie. changing the textbox)... 

    Thank you so much for any help!

    ------------------------------
    Stacy Seapy
    ------------------------------


  • 2.  RE: Single Button to Save & Keep Working Before Editing a Record (ex. change a checkbox)?

    Posted 11-24-2020 13:33
    Since the end result of each button example is a page reload, I don't think there's a way you can chain them together without making your own form in a code page and handling everything yourself.

    It's a bit hacky but if the checkbox you want to update is on the form, you could update its value before saving using DOM manipulation.   For example, if the field ID for your checkbox is 12:

    "<div class='Vibrant Success' onclick=$('#_fid_12').prop('checked',true);$('#footerSaveAndKeepWorkingMenuOption').click();>Generate Document</div>"

    ------------------------------
    Nathan Hawe
    ------------------------------



  • 3.  RE: Single Button to Save & Keep Working Before Editing a Record (ex. change a checkbox)?

    Posted 12-15-2020 09:46
    Thank you, Nathan!! 

    Your solution did the trick! The only slightly hacky part of the solution was creating two formula rich text fields that a form rule is set up to show/not show depending on if the trigger checkbox is/isn't selected (so clicking the button will either change the checkbox to true or false, as needed).

    I appreciate your help - I started down the rabbit trail of custom code/script pages and was quickly getting lost. Creating two "button" fields for each trigger field is well worth holding off on entering the world of code pages.

    ------------------------------
    Stacy
    ------------------------------



  • 4.  RE: Single Button to Save & Keep Working Before Editing a Record (ex. change a checkbox)?

    Posted 04-12-2022 14:01
    Edited by Joel Hickok 04-12-2022 14:01
    This is how I have made this work:
    https://www.youtube.com/watch?v=NzBt90zJ1Tg

    Thanks to the video producer for putting that together, because it helped my situation.  Not sure if it works for you at all.  I could see some basic changes to make this work for many use cases.

    ------------------------------
    Joel Hickok
    ------------------------------