append setFieldvalue in custom JS

Forums General discussion append setFieldvalue in custom JS

Viewing 1 reply thread
  • Author
    Posts
    • #16867
      Matthew Thompson
      Participant

      Here is the code I am attempting to append in custom JS within DFFS. Currently the two functions overwrite each other.

      //ACMSCOMMENTS
      function ACMSCOMMENTS() {
      var ACMS=getFieldValue(“ACMS__x0028_ACCOUNT_x0020_CLOSUR”);
      var AGENT=getFieldValue(“Agent”);
      var TIME=new Date();
      if (ACMS ==”Submitted for Access”) {
      setFieldValue(“Comments”,”ACMS – Submitted for Access (“+AGENT+” “+TIME+”)”);
      }else{
      setFieldValue(“Comments”,”ACMS – Access Request completed (“+AGENT+” “+TIME+”)”);
      }
      alert (“Comments Updated with Action”);
      }

      //AMLDEFCOMMENTS
      function AMLDEFCOMMENTS() {
      var ACMS=getFieldValue(“AML_DEFECT__x0028_AML_x0020_DEFE”);
      var AGENT=getFieldValue(“Agent”);
      var TIME=new Date();
      if (ACMS ==”Submitted for Access”) {
      setFieldValue(“Comments”,”AML_DEFECT – Submitted for Access (“+AGENT+” “+TIME+”)”);
      }else{
      setFieldValue(“Comments”,”AML_DEFECT – Access Request completed (“+AGENT+” “+TIME+”)”);
      }
      alert (“Comments Updated with Action”);
      }

    • #16872
      Alexander Bautz
      Keymaster

      Hi,
      You need to first pull the current value from the textarea, and then append the new text to it before adding it again to the field. Something like this:

      ...
      ...
      var TIME = new Date();
      var currentTEXT = getFieldValue("Comments") + "\n;
      if(ACMS =="Submitted for Access") {
          setFieldValue("Comments",currentTEXT+"AML_DEFECT – Submitted for Access ("+AGENT+" "+TIME+")");
      }else{
          setFieldValue("Comments",currentTEXT+"AML_DEFECT – Access Request completed ("+AGENT+" "+TIME+")");
      }
      ...
      ...

      Please note that I have appended “\n” to the “currentTEXT” variable to add a linefeed in the textarea.

      Let me know how it work out,
      Alexander

Viewing 1 reply thread
  • You must be logged in to reply to this topic.