MikeS

Forum Replies Created

Viewing 15 posts - 61 through 75 (of 157 total)
  • Author
    Posts
  • in reply to: Autonumber list items with DFFS #31106
    MikeS
    Participant

      How would I go about sequentially numbering (starting at ROM-0001 and correctly inserting leading zeros up to ROM-9999) regardless of a list item being deleted? Seems like I would need to keep an external count somewhere or run into the problem you noted in your August 9, 2016, post above.

      Thanks
      Mike

      in reply to: Autonumber list items with DFFS #31075
      MikeS
      Participant

        Alexander,

        How would you go about using a DFFS Rule to auto-increment a sequential number not based on the ID? The numbers should appear as follows (leading zeros based on next number to be used). This New Form rule would be triggered by membership in a SharePoint Permission Group. This allows other list adds to bypass this rule (dual function list).

        ROM-0001
        ….
        ROM-0099
        ….
        ROM-0100
        ….
        ROM-1000
        ….
        ROM-9999
        etc.

        Solutions I have used in the past involve a SPD WF and an external list that maintains the Last Number so as to assign the Next Number. This is not optimal for this context. Hopefully DFFS or a JS solution might be useful.

        Thanks
        Mike

        MikeS
        Participant

          That script change adds a line break for some reason (see attached screenshot).

          How could I format the main lookup field (TNLookup), e.g., in this line:
          jQspjs(“#dffs_TNLookup .ms-formbody a”).each(function (i, a) {

          or this line (not sure where the style commands should go):
          jQspjs(“#dffs_TNLookup .ms-formbody”).contents().filter(function () {

          Thanks,
          Mike

          MikeS
          Participant

            How could I add formatting (e.g., bold or font-size) to one of the displayed fields? That would help the lookup field stand out from the related fields.

            Thanks
            Mike

            MikeS
            Participant

              Yes. That was the issue and I had forgot to check that. The script works great now! Thanks for your help.
              Mike

              MikeS
              Participant

                I have done more testing and added back in a Date field without the numeric prefix. That works fine. See script and screen shot.

                However the Date field with the numeric prefix seems to be the issue. FIN has been checked. Still can’t get the console.log script to run w/o error even with the replaced line in the script.

                Is there another way to characterize the numeric date FIN in the script?

                jQspjs(“#dffs_TNLookup .ms-formbody a”).each(function (i, a) {
                var id = GetUrlKeyValue(“ID”, false, a.href);
                var listId = GetUrlKeyValue(“ListId”, false, a.href);
                var item = spjs.utility.getItemByID({
                “listName”: listId,
                “id”: id,
                “viewFields”: [“TNDecision”,”TNPOC”,”TNDate”,”123Date”]
                });
                var TNDecision1 = item.TNDecision;
                if(TNDecision1 === null){
                TNDecision1 = “[empty]”;
                }
                var TNPOC1 = item.TNPOC;
                if(TNPOC1 === null){
                TNPOC1 = “[empty]”;
                }
                var TNDate1 = item.TNDate;
                if(TNDate1 === null){
                TNDate1 = “[empty]”;
                }else{
                TNDate1 = new Date(item.TNDate.split(” “).join(“T”)).toLocaleDateString();
                }
                var Date123 = item[“123Date”];
                if(Date123 === null){
                Date123 = “[empty]”;
                }else{
                Date123 = new Date(item[“123Date”].split(” “).join(“T”)).toLocaleDateString();
                }
                var b = [];
                b.push(“TNDate: ” + TNDate1);
                b.push(“TNDecision: ” + TNDecision1);
                b.push(“TNPOC: ” + TNPOC1);
                b.push(“123Date: ” + Date123);
                jQuery(a).append(“<div>” + b.join(“<br>”) + “</div>”);
                });
                // Separate each item
                jQspjs(“#dffs_TNLookup .ms-formbody”).contents().filter(function () {
                return (this.nodeType === 3 && this.nodeValue === “; “);
                }).replaceWith(“<hr>”);

                MikeS
                Participant

                  The console log query placed in the Display form Custom JS (same place I have the script above) returns the following:

                  ReferenceError: listId is not defined.

                  Mike

                  MikeS
                  Participant

                    I keep getting an [empty] date returned with this mod. See screen shot.

                    Script:

                    jQspjs(“#dffs_TNLookup .ms-formbody a”).each(function (i, a) {
                    var id = GetUrlKeyValue(“ID”, false, a.href);
                    var listId = GetUrlKeyValue(“ListId”, false, a.href);
                    var item = spjs.utility.getItemByID({
                    “listName”: listId,
                    “id”: id,
                    “viewFields”: [“TNDecision”,”TNPOC”,”123Date”]
                    });
                    var TNDecision = item.TNDecision;
                    if(TNDecision === null){
                    TNDecision = “[empty]”;
                    }
                    var TNPOC = item.TNPOC;
                    if(TNPOC === null){
                    TNPOC = “[empty]”;
                    }
                    var Date123 = item[“123Date”];
                    if(Date123 === null){
                    Date123 = “[empty]”;
                    }else{
                    Date123 = new Date(item[“123Date”].split(” “).join(“T”)).toLocaleDateString();
                    }
                    var b = [];
                    b.push(“TNDecision: ” + TNDecision);
                    b.push(“TNPOC: ” + TNPOC);
                    b.push(“123Date: ” + Date123);
                    jQuery(a).append(“<div>” + b.join(“<br>”) + “/<div>”);
                    });
                    // Separate each item
                    jQspjs(“#dffs_TNLookup .ms-formbody”).contents().filter(function () {
                    return (this.nodeType === 3 && this.nodeValue === “; “);
                    }).replaceWith(“<hr>”);

                    One other thing: I had to remove the ‘/’ before the closing div or it would appear in the UI. Doesn’t seem like a good work-around due to markup standards. You can see the ‘/’ in the attached screen shot.

                    Mike

                    MikeS
                    Participant

                      Much better! This will work.

                      One issue: I have field names that start with numeric values, e.g., 123Date, and the script throws an error in the CustomJS box. Is there a way to escqpe such fields in the script? Changing field names is not an option.

                      UI thing: the <hr> hardly shows up between records. Original script had a dark line.

                      Thanks,
                      Mike

                      MikeS
                      Participant

                        There could be multiple items with one of more blank (empty) Related Fields. For example the TNDate field could be empty on one or all Lookups. I’m fine with testing for that, but still getting error on form load (TypeError: item.TNDate is null) and no <hr> break between records with multiple lookups.

                        A single lookup with empty Related Fields displays fine.

                        Script:
                        jQspjs(“#dffs_TNLookup .ms-formbody a”).each(function (i, a) {
                        var id = GetUrlKeyValue(“ID”, false, a.href);
                        var listId = GetUrlKeyValue(“ListId”, false, a.href);
                        var item = spjs.utility.getItemByID({
                        “listName”: listId,
                        “id”: id,
                        “viewFields”: [“TNDecision”,”TNPOC”,”TNDate”]
                        });
                        var b = [];
                        b.push(“<br>TNDecision: ” + (item.TNDecision !== null ? item.TNDecision : “”));
                        b.push(“TNPOC: ” + (item.TNPOC !== null ? item.TNPOC : “”));
                        b.push(“TNDate: ” + item.TNDate !== null ? new Date(item.TNDate.split(” “).join(“T”)).toLocaleDateString() : “”);
                        jQuery(a).append(b.join(“<br>”));
                        });
                        // Separate each item
                        jQspjs(“#dffs_TNLookup .ms-formbody”).contents().filter(function () {
                        return (this.nodeType === 4 && this.nodeValue === “; “);
                        }).replaceWith(“<hr>”);

                        Mike

                        MikeS
                        Participant

                          Revised JS

                          `jQspjs(“#dffs_TNLookup .ms-formbody a”).each(function (i, a) {
                          var id = GetUrlKeyValue(“ID”, false, a.href);
                          var listId = GetUrlKeyValue(“ListId”, false, a.href);
                          var item = spjs.utility.getItemByID({
                          “listName”: listId,
                          “id”: id,
                          “viewFields”: [“TNDecision”,”TNPOC”,”TNDate”]
                          });
                          var b = [];
                          b.push(“<br>TNDecision: ” + item.TNDecision);
                          b.push(“TNPOC: ” + (item.TNPOC !== null ? item.TNPOC : “”));
                          b.push(“TNDate: ” + new Date(item.TNDate.split(” “).join(“T”)).toLocaleDateString());
                          jQuery(a).append(b.join(“<br>”));
                          });
                          // Separate each item
                          jQspjs(“#dffs_TNLookup .ms-formbody”).contents().filter(function () {
                          return (this.nodeType === 4 && this.nodeValue === “; “);
                          }).replaceWith(“<hr>”);’

                          Gives me this error in the Display form when launching

                          DFFS: There is an error in the Custom JS textarea:
                          *************************************
                          TypeError: item.TNDate is null
                          *************************************
                          Please enter setup and revise.

                          The Display form then has incorrect formatting as shown in attached screen shot.

                          Mike

                          MikeS
                          Participant

                            I keep getting a field value of NULL returned for the Related Fields, or an error message to that effect.

                            My script:
                            `jQspjs(“#dffs_TNLookup .ms-formbody a”).each(function (i, a) {
                            var id = GetUrlKeyValue(“ID”, false, a.href);
                            var listId = GetUrlKeyValue(“ListId”, false, a.href);
                            var item = spjs.utility.getItemByID({
                            “listName”: listId,
                            “id”: id,
                            “viewFields”: [“TNLookup_x003a_TNDecision”,”TNLookup_x003a_TNPOC”,”TNLookup_x003a_TNDate”]
                            });
                            var b = [];
                            b.push(“<br>TNDecision: ” + item.TNLookup_x003a_TNDecision);
                            b.push(“TNPOC: ” + (item.TNLookup_x003a_TNPOC !== null ? item.TNLookup_x003a_TNPOC : “”));
                            b.push(“TNDate: ” + new Date(item.TNLookup_x003a_TNDate.split(” “).join(“T”)).toLocaleDateString());
                            jQuery(a).append(b.join(“<br>”));
                            });
                            // Separate each item
                            jQspjs(“#dffs_TNLookup .ms-formbody”).contents().filter(function () {
                            return (this.nodeType === 3 && this.nodeValue === “; “);
                            }).replaceWith(“<hr>”);’

                            Screen shots are attached.

                            Thanks for your help. The UI looks like it will work fine once this is resolved.
                            Mike

                            • This reply was modified 4 years, 6 months ago by MikeS.
                            MikeS
                            Participant

                              Awesome solution Alexander. Works perfectly. Thank you!

                              Mike

                              MikeS
                              Participant

                                Alexander,

                                I’ve worked for some time with the AutoComplete plug-in based on your suggestion. I’m unable to get a concatenated list of the three fields in the toFIN field. All I see in the toFIN box is the last field specified in the array. Do my array statements look OK?

                                
                                
                                "setFields": [
                                     {
                                			"fromFIN":"Title",
                                			"joinBy":",",
                                			"toFIN":"RackCombo",
                                			"parseFunction":"",
                                			"skipIfEmpty":true
                                		},
                                		{
                                			"fromFIN":"SerialNo",
                                			"joinBy":",",
                                			"toFIN":"RackCombo",
                                			"parseFunction":"",
                                			"skipIfEmpty":true
                                		},
                                		{
                                			"fromFIN":"MfrDate",
                                			"joinBy":",",
                                			"toFIN":"RackCombo",
                                			"parseFunction":"",
                                			"skipIfEmpty":true
                                		},

                                Once I get that solved I still need to be able to add additional sets of three fields to the same toFIN text box (or another text box) with a <br> separating each set of three fields – like a collector or aggregator text box. Any tips on that would be much appreciated.

                                Thanks
                                Mike

                                MikeS
                                Participant

                                  Alexander,

                                  I would appreciate you assistance on a variation of this code.

                                  I’m using a DFFS cascading dropdown in an Inventory list with a multi-choice on a Rack Number field from a lookup to a Rack number list. I need to select one or more Rack Numbers in my Inventory list and automatically pull forward additional fields from the Rack list. These additional fields (Serial Number, Mfr Date) do not need to be part of any dropdown in the Inventory List as they are fixed for each Rack. However they should be visible below the Lookup field when a Rack No is chosen. (There will be duplicate Rack Numbers in the Rack Number list but your code above does a good job of just showing one Rack Number in the lookup field no matter how many duplicates.)

                                  I then need to concatenate each Rack No and the pulled forward additional fields in a multi-line Rich Text field (with line breaks) in my Inventory list. It appears I must use a Rich Text field for this collection of concatenated fields as I need a line break that will translate to a Word document (via a SPD Workflow) and show up as a set of rows (like a table) rather than one long string.

                                  Example of the final multi-line field in SharePoint:
                                  Rack1 – Serial Number, Mfr Date </br>
                                  Rack2 – Serial Number, Mfr Date </br>
                                  etc.

                                  Thanks for your help,
                                  Mike

                                Viewing 15 posts - 61 through 75 (of 157 total)