Discussions

Expand all | Collapse all

How do I delete the entries in a field with logging turned on based on a change in another field's value?

  • 1.  How do I delete the entries in a field with logging turned on based on a change in another field's value?

    Posted 10-20-2016 21:29

    I have an 'Approvals' field that has logging turned on to capture whether all approvers have approved or not - however, there is a use case where the approval cycle starts over and the previous approvals no longer apply.  I need to delete the approval history from that field.



  • 2.  RE: How do I delete the entries in a field with logging turned on based on a change in another field's value?

    Posted 10-20-2016 22:51
    You can make formula URL button for s user to click which will reset the logging field.

    This formula below changes the field to no longer be a logged field then it edits the record to blank out the field, and then it turns the looting back on.
    This is the same thing that you would need as an admin.

    But I think that the users need to have permissions to edit field properties to Allie this technique to work.

    In thinking about that permissions issue, the hold played solution would be to turn this into a web hook, because a webhook runs under a predefined userid which can have s high permission level.

    Contact me off line if you want help setting up s webhook.

    Here is the code for the button.
    var text ClearNotesAppendOnlyIMUndo = URLRoot() & "db/" & Dbid() & "?act=API_SetFieldProperties&fid=273&append_only=0";
    var text ClearIMApproval = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#]) & "&_fid_273=";
    var text ClearNotesAppendOnlyIMRedo = URLRoot() & "db/" & Dbid() & "?act=API_SetFieldProperties&fid=273&append_only=1";




    var text Display = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & ToText([Record ID#]);



    $ClearNotesAppendOnlyIMUndo
    & "&rdr=" & URLEncode($ClearIMApproval)
    & URLEncode("&rdr=" & URLEncode($ClearNotesAppendOnlyIMRedo))


  • 3.  RE: How do I delete the entries in a field with logging turned on based on a change in another field's value?

     
    Posted 06-28-2018 09:46
    Hey Mark, 

    When you say "turn this into a webhook" do you mean a webhook that momentarily increases the permission level of the user such that the button can be executed by a non-admin, or do you mean turn the entire action of clearing the logged history into a webhook?


  • 4.  RE: How do I delete the entries in a field with logging turned on based on a change in another field's value?

    Posted 06-28-2018 10:02
    It�s a tricky problem.

    You can increase the Permission level of all users to be able to edit field properties. But the danger is that they will right-click a field and get into a field property and say delete it. That would be bad.

    The alternative would be to get those steps run as a Webhook as it runs under its own permissions with a usertoken and not the users Low permissions, , but that�s messy too as you need to have the steps run in sequence and I don�t think you can control the sequence of Webhooks


  • 5.  RE: How do I delete the entries in a field with logging turned on based on a change in another field's value?

     
    Posted 06-29-2018 02:47
    Is that because a webhook can only contain one action at a time? 

    I'm trying to figure out how to turn the URL formula you've written above into XML form, but I'm not sure if it's possible to string multiple actions together into one XML code...


  • 6.  RE: How do I delete the entries in a field with logging turned on based on a change in another field's value?

    Posted 06-29-2018 04:59
    As far as I know, a weekhook can only execute 1 AP1.


  • 7.  RE: How do I delete the entries in a field with logging turned on based on a change in another field's value?

    Posted 12-14-2016 17:35
    Awesome solution Mark, thanks!!