error when using setFieldValue

Forums SPJS-Utility error when using setFieldValue

Viewing 1 reply thread
  • Author
    Posts
    • #16818
      Jeff Lynch
      Participant

      We have built a custom function to set the due date based on the current date/time, we are using the setFieldValue and it is returning an error:
      DFFS: Configuration error in “Run these functions / trigger these rules”. Ensure you use the correct function name or rule friendly name.

      The rule “Due Date” tried to invoke the function:
      “setDuedate”

      Error:
      TypeError: a.newVal.split is not a function

      Here is our function:
      setDuedate = function(priority){

      var duedate = new Date();

      if(priority == “Critical”){
      var temp;
      if(duedate.getHours() <= 12){
      temp = 17;
      }else{
      temp = created.getHours() – 4;
      duedate.setDate(duedate.getDate()+1);
      }
      duedate.setHours(temp);
      }else if(priority == “Urgent”){
      duedate.setDate(duedate.getDate()+1);
      }else if(priority == “Basic”){
      duedate.setDate(duedate.getDate()+2);
      }else{
      duedate.setDate(duedate.getDate()+10);
      }

      if(duedate.getDay() === 0){
      duedate.setDate(duedate.getDate()+1);
      }else if(duedate.getDay() == 6){
      duedate.setDate(duedate.getDate()+2);
      }

      setFieldValue(“SLA_x0020_Due”,duedate);
      };

      can you help debug this one?

    • #16823
      Alexander Bautz
      Keymaster

      The setFieldValue cannot use the date object directly – it needs the value in a string format like this “06/17/1017”. Change your code like this:

      setDuedate = function(priority){
      ...
      ...
      var sDate = spjs.utility.dateObjToFormattedString(duedate,"dd/MM/yyyy");
      setFieldValue("SLA_x0020_Due",sDate);
      };

      Alexander

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