Appended Multi-Line Text Field Questions

Home Forums Classic DFFS Appended Multi-Line Text Field Questions

Tagged: 

Viewing 9 reply threads
  • Author
    Posts
    • #20423
      Notrega
      Participant

        I have a multi-line plain text field that appends {FIELD1}, and I need the last entry as plain text in a html formatted letter. When I use {FIELD1} in the html it gives me all of the appended history, but I need just the last entry. So I used the code below from another thread to trigger a rule that sets another non-appending text field {FIELD2} and it works… until I touch the record again then the blank/empty append on {FIELD1} results in the rule emptying {FIELD2}.

        Is there an easier way to do what I want to do or is there something that I am missing?

        
        
        // Plain text fields
        $("#dffs_FIELD1 textarea").on("change",function(){
            spjs.dffs.triggerRule(["MultiLineTrigger"]);
        });
        
        // Enhanced Rich text fields
        var initialRteVal = getFieldValue("FIELD1").replace(/<[^>]*>/g,"");
        $("#dffs_FIELD1 div.ms-rtestate-write").on("blur",function(){
            var currVal = getFieldValue("FIELD1").replace(/<[^>]*>/g,"");
            if(currVal !== initialRteVal){
                spjs.dffs.triggerRule(["MultiLineTrigger"]);
            }
        });

        By the way – I just got access to DFFS last week and it is AWESOME!!! Thanks for a great tool!!!!

      • #20425
        Notrega
        Participant

          Never mind – it is working now… I think LOL

          If there is a better way I still would appreciate it.

        • #20433
          Keith Hudson
          Participant

            NOTE that the “Append to existing text” choice is horribly misnamed. It would be better named “show prior versions”. I never use it. Ever. Instead, I use a multi-lines of text plain text field.

            The easiest way to use it is to manually add text to the plain text field. Usually, however, I want to include a date and author stamp for each added piece of text, so just above that field on my form I insert a button using an html section, that runs a custom javascript function to create a timestamp and author stamp and pre-pend those to the existing text in the field, and position the cursor so I can just type my additional text after clicking the button.

            IF you need more details, post here and I’ll try to get time to capture some code and screenshots and add them to this discussion.

          • #22776
            MikeS
            Participant

              Keith,
              I am interested in the JS code you mentioned above as I have several multi-line text fields in which multiple users enter text. Their self-submitted initials and date annotations are all over the board. Your JS would be helpful.

              Thanks
              Mike

            • #22832
              Notrega
              Participant

                I would be interested in Keith’s approach as well.

              • #22897
                Keith Hudson
                Participant

                  Sorry for the delay in responding.

                  I am attaching a Word document with code and screenshots to explain my approach when using an Enhanced Rich Text field. In this approach, the author and timestamp is bolded.

                • #22905
                  MikeS
                  Participant

                    Thanks Keith! Nice write-up. After a bit of experimentation I have two questions:

                    1. I only need the Date, not the Time or the Day. Your JS produces: 11/26/2018, 12:08:39 PM. What is the JS to parse the timestamp and just print the Date, i.e., 11/26/2018?
                    2. For some reason the only way I can get a line break is by placing the <br> as follows:
                      setFieldValue('Notes','<br><b>'+ dateTime +' '+ user +': </b>'+oldComment);

                      This inserts a blank line at the top of the aggregated comments. Any suggestions?

                    Thanks!
                    Mike

                    • This reply was modified 6 years, 1 month ago by MikeS.
                  • #22939
                    Keith Hudson
                    Participant

                      1a. Here’s JS code to get a timestamp. Wrap it in a function and call it. Modify it as needed to get the portion of the timestamp you want.

                      var today = new Date();
                      var dd = today.getDate();
                      var mm = today.getMonth()+1; //January is 0!
                      var yyyy = today.getFullYear();
                      if(dd<10) {
                          dd='0'+dd
                      } 
                      if(mm<10) {
                          mm='0'+mm
                      } 
                      today = mm+'/'+dd+'/'+yyyy;

                      1b. By looking at the tooltip for “Set Field Value” on the Rules configuration page in DFFS, we see we can use {timestamp[dd.MM.yyyy hh.mm.ss]} to format the DFFS timestamp function. So, you could try changing the line

                      var dateTime=spjs.dffs.buldValStr("{timestamp}");

                      to

                      var dateTime=spjs.dffs.buldValStr("{timestamp[dd.MM.yyyy]}");

                      I have never tested this.

                      Good luck.

                      Separate answer coming for #2 once I have time to parse the question.

                      • This reply was modified 6 years, 1 month ago by Keith Hudson.
                      • This reply was modified 6 years, 1 month ago by Keith Hudson.
                    • #22943
                      Keith Hudson
                      Participant

                        #2: All I can suggest is experimenting with different placement of the line break tag. In this case, trial and error is your friend.

                      • #27782
                        Brett
                        Participant

                          This worked for me, exactly what I was after.
                          Just tried Keiths script from the Word doc and used it in a rule to trigger the customjs.
                          Expanded the date/time and rearranged the variables.

                          setFieldValue('ActionPerformed','Updated Contract by: ' + user + ' on: ' + dateTime + '<br>' + oldComment  );

                          Thanks heaps for sharing.

                      Viewing 9 reply threads
                      • You must be logged in to reply to this topic.