Keith Hudson

Forum Replies Created

Viewing 10 posts - 91 through 100 (of 100 total)
  • Author
    Posts
  • 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

      • This reply was modified 8 years, 6 months ago by Keith Hudson.
      • This reply was modified 8 years, 6 months ago by Keith Hudson.
      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 8 years, 6 months ago by Keith Hudson. Reason: improve spacing
        in reply to: Updating DFFS #16590
        Keith Hudson
        Participant

          I must have fat-fingered something the first time I tried renaming my DFFS folder, because I just tried it again and it worked like a charm.

          Keith Hudson
          Participant

            Yes, I was using a table within the HTML and adding the style “border-collapse:collapse” solved the problem. Thanks, Alex!

            in reply to: How add SPServices as a plugin? #15889
            Keith Hudson
            Participant

              I’m using SPServices GetListItems function to get text contained in another list on my site to display on the form.

              If there is functionality in DFFS to do that already, I would love to use that.

              As far as including SPServices, all I need to do is include a script reference in the Custom JS config page, like this?

              eg http://[url%20to%20SPServices]

              in reply to: Rules opening wrong form, combination rules not working #13531
              Keith Hudson
              Participant

                After some more testing, it appears I was misunderstanding the rule operation. I had set the FormB rule somthing like “when Request Type is changed from initial value” and inserted the target value in the value field, not realizing that for a change from initial value, ANY value will do. I changed the FormB rule to “when Request Type is equal to” my value, and it is working correctly.

                I still don’t know why my combination rules weren’t working before, but I’ll leave that puzzle for another day.

                Once again, a huge shout out to Alex for this great tool!!

                in reply to: Button as HTML that triggers a rule #9693
                Keith Hudson
                Participant

                  David; you can trigger a rule from a button like this:

                  <button type="button" onclick="spjs.dffs.triggerRule(['Append']);">Test</button>

                  My ‘Append’ rule sets the value of Box_1 to “{Box_1} {Box_2}”.

                  So, when Box_1 = “One fish” and Box_2 = “Two fish”, after pressing the button on my form, Box_2 = “One fish Two fish”.

                  If you want to insert a line break when appending, your rule would look like this: {Box_1}\n{Box_2}

                  Based on my testing, that will work for either plain text OR enhanced rich text fields.

                  NOTE 1: DFFS is incompatible with Rich text fields, as far as I know.
                  NOTE 2: I tested using the Dec 14, 2015 version of DFFS.

                  in reply to: Adding "Save and Stay on Page" button in Edit form? #7477
                  Keith Hudson
                  Participant

                    I succeeded in changing the onclick event of the Save button to save the record then post back to the edit form, BUT it seems that SharePoint 2013 handles multi-line text fields in some unusual way, because edits made to those fields did not get saved. Anyone attempting to add Save and Stay on Page functionality needs to test thoroughly that all fields are getting saved correctly before putting their solution into production.

                    in reply to: Adding "Save and Stay on Page" button in Edit form? #7429
                    Keith Hudson
                    Participant

                      I discovered that the approach I just posted saves SOME fields and not others, so its back to the drawing board.

                      in reply to: Adding "Save and Stay on Page" button in Edit form? #7428
                      Keith Hudson
                      Participant

                        I ran across this blog which gave me the headstart I needed: https://adrianhenke.wordpress.com/2010/08/19/custom-redirect-after-creating-a-new-sharepoint-item/

                        The code I added to the JS Section of the Misc tab in the DFFS config of my Edit form is as follows:

                        //this function renames the Save button to “Save and Stay on Page” and causes the save button to return to the same edit form it came from.

                        $(document).ready(function() {
                        var button = $(“input[id$=SaveItem]”);
                        button.attr(“value”,”Save and Stay on Page”);
                        // change redirection behavior
                        button.removeAttr(“onclick”);
                        button.click(function() {
                        var elementName = $(this).attr(“name”);
                        var aspForm = $(“form[id=aspnetForm]”);
                        var oldPostbackUrl = aspForm.get(0).action;
                        var newPostbackUrl = oldPostbackUrl + “&Source=” +oldPostbackUrl;
                        if (!PreSaveItem()) return false;
                        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, “”, true, “”, newPostbackUrl, false, true));
                        });
                        }); //end ready function

                      Viewing 10 posts - 91 through 100 (of 100 total)