Discussions

 View Only
  • 1.  automatically edit record after copyMasterDetail

    Posted 05-13-2016 20:32
    So in a single form I have two fields worth mentioning.

    a formula checkbox watching for "copy of" to appear it is true when present. and if opened in edit while true a rule will clear that field

    and another formula text that contains this:

    var text base = URLRoot() & "db/" & Dbid();

    var text eAPI = $base & "?a=er&rid=" & [Record ID#]&"&ticket=" & [Ticket] & "&apptoken=" & [Token];

    var text cJS="javascript:void(copyMasterDetailButtonHandler('&relfids=192,194,250&copyFid=327&destrid=0&sourcerid=" & [Record ID#] & "','"& Dbid()&"'))";

    var text cop =  "<a id='userButton' class='Vibrant Primary' href=\"" &  $cJS &"\">Copy Detailed Quote</a>";

    var text unl = "<a id='userButton' class='Vibrant Danger' href=" &$eAPI &"\">Unlock and edit this Quote</a>";

    var text InnerText=

    If([Clone Trigger]=true,$unl,$cop);

    $InnerText

    the second part of the button is currently a failsafe incase they back out of the record before saving. How would i modify this further to include a redirect to the edit record $eAPI Or set up a script to hijack the browser to redirect based on [Clone Tigger] true value by replacing $unl


  • 2.  RE: automatically edit record after copyMasterDetail

    Posted 05-15-2016 22:41
    well no one else helped me so I ended up doing this for the button code:



        var text base = URLRoot() & "db/" & Dbid();
        var text eAPI = $base & "?a=er&rid=" & [Quote ID#]&"&ticket=" & [Ticket] & "&apptoken=" & [Token];
        var text cJS ="javascript:void(copyMasterDetailButtonHandler('&relfids=192,194,250&copyFid=327&destrid=0&sourcerid=" & [Quote ID#] & "','"& Dbid()&"'))";
        var text cop = "<a id='userButton' class='Vibrant Primary' href=\"" & $cJS &"\">Copy Detailed Quote</a>";
        var text unl = "<a id='userButton' class='Vibrant Danger' href=" &$eAPI &"\">Click if not redirected to unlock and edit</a>";
        var text red =$unl &"<br>"&[iol]&"redirect.js"&[/iol];
        var text InnerText=
        If([Clone Trigger]=true,$red,$cop);

        $InnerText




    and in the script redirect.js:

        (function() {
          //get url string
          var str = window.location.href;
          //change view to edit
          String.prototype.replaceAt = function(str, character) {
            return this.substr(0, str) + character + this.substr(str + character.length);
          }
          str = str.replaceAt(49, "e");
          setTimeout(function() {
            window.location.href = str;
          }, 800);

        })();



    which just takes it from view to edit


  • 3.  RE: automatically edit record after copyMasterDetail

    Posted 03-28-2017 02:44
    I will try this code.


  • 4.  RE: automatically edit record after copyMasterDetail

    Posted 04-01-2017 18:43
    One thing I did not take into account is the way XML uses the text, The following function was added and each text node was wrapped in the function.
    function escapeXml(unsafe) {    return unsafe.replace(/[<>&'"]/g, function (c) {
            switch (c) {
                case '<': return '&lt;';
                case '>': return '&gt;';
                case '&': return '&amp;';
                case '\'': return '&apos;';
                case '"': return '&quot;';
            }
        });
    }

    And for clarification on why I have such a round about way is because we have looping relationships on the tables involved and the manager only wanted specific fields copied instead of all of them.