DFFS Built-in Function Reference – seeking volunteers

Forums Dynamic Forms for SharePoint DFFS Built-in Function Reference – seeking volunteers

Viewing 15 reply threads
  • Author
    Posts
    • #16591
      Keith Hudson
      Participant

      This is a call for anyone who would like to collaborate on producing a reference showing all the built in functions in DFFS that we can use in our custom JS code. I’m sure Alex could produce one, but I’d like to see if we could start a working group to take that load off Alex and produce at least a draft of such a reference ourselves, then ask Alex to review it/correct it/add to it. I would be glad to host it on a web site if needed, although Alex might be willing to add it somewhere on this site.

      Is anyone interested in having such a reference? Helping build it?

    • #16622
      Alexander Bautz
      Keymaster

      Hi Keith,
      Not much response yet, but I hope more people will post their code examples here – I’m sure it will be of great help for others to have a set of examples / references.

      As you know I’m a bit to busy to be able to write it up myself, but I’ll do my best to help out with any questions.

      Thanks for the initiative,
      Alexander

      PS: I made it sticky.

    • #16633
      Keith Hudson
      Participant

      // get/set field values.
      // NOTE values are read from or written to the input field as strings.
      // On save, they are converted by SP to the right data type
      getFieldValue(‘FIN’)
      setFieldValue(‘FIN’ , ‘valueToSet’)

      • This reply was modified 2 years, 6 months ago by  Keith Hudson. Reason: improve spacing
    • #16640
      Keith Hudson
      Participant

      //spjs_QueryItems
      //retrieve items from a list
      //takes an object containg the following parameters:
      //listName, query, viewFields
      spjs_QueryItems(argObj)

      example:
      function getMacros(){
      var fieldName = “Title”;
      var fieldType = “Text”;
      var listName = “Foods”;
      var targetString = getFieldValue(“Food”);
      var qty = getFieldValue(“Qty”);
      var res, qb = [], item;
      qb.push(“<Where>”);
      qb.push(“<Eq>”);
      qb.push(“<FieldRef Name='” + fieldName + “‘/><Value Type= ‘” + fieldType + “‘>” + targetString + “</Value>” );
      qb.push(“</Eq>”);
      qb.push(“</Where>”);
      res = spjs_QueryItems({“listName”:listName,”query”:qb.join(“”),”viewFields”:[“PctFat”,”CalTot”,”PctCarb”,”PctProtein”]});
      if(res.count > 0){
      item = res.items[0];
      setFieldValue(“TotCal”,item.CalTot !== null ? item.CalTot*qty: “not set”);
      setFieldValue(“PctFat”,item.PctFat !== null ? item.PctFat*100: “not set”);
      setFieldValue(“PctCarb”,item.PctCarb !== null ? item.PctCarb*100: “not set”);
      setFieldValue(“PctProtein”,item.PctProtein !== null ? item.PctProtein*100: “not set”);
      }
      }

      Forum articles:
      get values from another list/
      vlookup-from-new-on-separate-list

    • #19322
      Keith Hudson
      Participant

      Putting Prev/Next tab buttons at the top of the form:

      The easiest way to achieve this is to add this snippet to your custom js. You don’t need to use the Misc settings if you only want the buttons in the top.

      var b = [];
      b.push("<div style='padding:2px;text-align:right;border-bottom: 1px #808080 solid;'>");
      b.push("<input class='ms-ButtonHeightWidth' type='button' value='Previous tab' onclick='spjs.dffs.navTab(0);'>");
      b.push("<input class='ms-ButtonHeightWidth' type='button' value='Next tab' onclick='spjs.dffs.navTab(1);'>");
      b.push("</div>");
      jQuery(".dffsTabRow").after(b.join(""));

      (gleaned from https://spjsblog.com/forums/topic/general-dffs-enhancement-suggestions/#post-19314)

      • This reply was modified 1 year, 10 months ago by  Alexander Bautz. Reason: Wrapped code snippet in <code></code>
    • #19324
      Keith Hudson
      Participant

      Redirecting user after Save button:

      You can use this code in your custom js:

      spjs.dffs.redirect(“http://Your_redirect_url&#8221;,false);
      The redirect will be performed when saving the form.

      (Gleaned from https://spjsblog.com/forums/topic/general-dffs-enhancement-suggestions/#post-19314)

    • #19602
      Keith Hudson
      Participant

      You can use this snippet to insert a timestamp in Custom JS:

      spjs.dffs.buildValStr(“{timestamp[dd.MM.yyyy hh:mm:ss]}”);
      // Outputs 03.02.2018 16:27:06

      From https://spjsblog.com/forums/topic/using-timestamp-in-custom-js/

    • #20828
      Keith Hudson
      Participant

      Get current user name

      var userInfo = spjs.utility.userInfo(spjs.dffs.data.currUserID);
      // userInfo is an object with multiple properties – use console.log(userInfo) to see all
      // Here is the title
      alert(userInfo.Title);

      from: https://spjsblog.com/forums/topic/internal-function-to-get-current-logged-in-user/

    • #20830
      Keith Hudson
      Participant

      make all visible tabs readonly, and set current tab fields to editable:

      https://spjsblog.com/forums/topic/easy-way-to-make-all-fields-readonly/

    • #20894
      Keith Hudson
      Participant

      Using Created and Created By in DFFS

      Start by adding a HTML section in the tab with the Unique ID “CreatedBy”.Then add this to the Custom JS:
      (function addCreatedByToTab(){
      var b = [];
      b.push(“<tr>”);
      b.push(“<td class=’ms-formlabel’>”);
      b.push(“<span class=’ms-h3 ms-standardheader’>Created by</span>”);
      b.push(“</td>”);
      b.push(“<td class=’ms-formbody’>”);
      b.push(spjs.dffs.beforeProperties.Author[0]);
      b.push(“</td>”);
      b.push(“</tr>”);
      jQuery(“#dffsHTML_CreatedBy”).replaceWith(b.join(“”));
      })();

      from: https://spjsblog.com/forums/topic/using-created-and-created-by-in-forms/

    • #20929
      Keith Hudson
      Participant

      Changing tab colors

      /* Style base tab */
      li.tabBase a{
      background-color:gray!important;
      padding:0 2px!important;
      }
      li.tabBase span{
      color:black!important;
      }
      /* Style selected tab */
      li.tabSelected a{
      background-color:green!important;
      padding:2px!important;
      }
      li.tabSelected a span{
      color:yellow!important;
      }

      from https://spjsblog.com/forums/topic/css-style-of-selected-tab/

    • #20935
      Keith Hudson
      Participant

      spjs.dffs.triggerSave(); saves record

    • #20952
      Keith Hudson
      Participant

      Programmatically set required field:

      Required fields are stored in this array:
      spjs.dffs.data.requiredFields

      and you can push in new fields like this
      // Push new required field into array
      spjs.dffs.data.requiredFields.push(“YourFieldName”);
      // Show star on all required fields
      spjs.dffs.starRequired();

      If you need to remove a field from the array, you can use this function:
      spjs.dffs.data.requiredFields = spjs.dffs.removeFromArr(spjs.dffs.data.requiredFields,”YourFieldName”);

      From: https://spjsblog.com/forums/topic/programmatically-set-required-field/
      See also: https://spjsblog.com/forums/topic/programmatically-set-field-to-required-based-on-multiple-inputs/

    • #21634
      Keith Hudson
      Participant

      Set All Fields on a Tab to readonly:

      Add this snippet to your Custom JS and call it from the “Click function name” in your tab:

      function readOnlyAllFieldsInTab(){
      var arrToSetReadonly = [];
      jQuery.each(spjs.dffs.data.tabConfigObj[spjs.dffs.data.selectedTab].fields,function(i,fin){
      if(spjs.dffs.fieldData[fin] !== undefined){
      arrToSetReadonly.push(fin);
      }
      });
      spjs.dffs.doReadOnly(arrToSetReadonly);
      }
      Please note that the fields will stay read-only when you change tabs – you would have to set the fields as editable again in the other tabs.

    • #22175
      Keith Hudson
      Participant

      Add Prev/Next buttons at top of form

      var b = [];
      b.push("<div style='padding:2px;text-align:right;border-bottom: 1px #808080 solid;'>");
      b.push("<input class='ms-ButtonHeightWidth' type='button' value='Previous tab' onclick='spjs.dffs.navTab(0);'>");
      b.push("<input class='ms-ButtonHeightWidth' type='button' value='Next tab' onclick='spjs.dffs.navTab(1);'>");
      b.push("</div>");
      jQuery(".dffsTabRow").after(b.join(""));

      from: https://spjsblog.com/forums/topic/general-dffs-enhancement-suggestions/#post-19314

      • This reply was modified 1 year, 2 months ago by  Alexander Bautz. Reason: fixed code snippet
    • #25530
      Keith Hudson
      Participant
Viewing 15 reply threads
  • You must be logged in to reply to this topic.