This project has moved. For the latest updates, please go here.
1

Closed

SPDisplayRelatedInfo not working in SPServices 2014.01

description

Hope I'm not missing the wood for the trees, but I have downloaded SPServices 2014.01 Beta to get a handle on the impact on my existing code made by the whole 'Required Field' debacle.

During my testing I'm not certain the SPDisplayRelatedInfo function is working as I am getting a Firebug error: 'TypeError: findFormField(...) is undefined' on the pages that use this function.

If you already know of this and is on the work stack, then please accept my apologies else if there's any further light I can shed, then please shout out.

I'm now back to rocking in my chair mumbling : "It was all working so nicely!"
Closed Aug 12, 2014 at 3:42 PM by sympmarc
Fixed/added/closed in 2014.01

comments

sympmarc wrote Feb 17, 2014 at 4:05 AM

Is your form customized in any way? What version of SharePoint? What CU level?

M.

fairfieldbusserv wrote Feb 17, 2014 at 6:34 AM

Sorry for the paucity of detail there Marc; has been a frustrating day trying to pick over things and I fired off the issue just before I left work for the day.

I'm running a series of new/edit/display forms on SP Online (v15.0.0.4455) created through SharePoint Designer 2013 with code injected through Script Editor WPs referencing various .js files which reference the field names are format the form presentation accordingly.

The columnName, relatedList and relatedListColumn values are referenced correctly and indeed I have not touched this code for a good few months. It was working fine, and the only thing I can think of that has changed is the Required Field change.

Incidentally my 'columnName' is a non-Required field which contains the List Item ID of the related list.

I am continuing to test, so will update this issue with anything pertinent.

Regards

Simon

fairfieldbusserv wrote Feb 17, 2014 at 6:48 AM

As a comparison I have reinstated jquery.SPServices-2013.01.min.js and added Mark Rackley's hack:
$(“[title$=' Required Field']“).each(function()
{
$(this).attr(“title”,$(this).attr(“title”).replace(” Required Field”,”"))
});
and things are back to 'normal'.

It's a means to an end...for now!

sympmarc wrote Feb 17, 2014 at 1:48 PM

If it's a non-required column, then the hack wouldn't work, either, so it must be. It's only the columnName which would matter, as it is the one rendered in the DOM.

Can you grab the markup for the ms-formbody element containing the dropdown and post it here? I don't need to see any of the option elements, just the select/input element(s).

M.

sympmarc wrote Feb 18, 2014 at 2:46 PM

I found the bug here, and it's fixed in 2014.01BETA2, which I am uploading now. Thanks for catching this. It came up at one of my clients, too, so I was able to debug it.

sympmarc wrote Feb 18, 2014 at 2:48 PM

For the record, the issue was that I was trying to find a "simple" dropdown using the column comment to handle SharePoint 2010 with the December CU. The error was thrown when the column was not in the page.

Split the logic out into it's own section to handle undefined cases:
        // Last ditch effort
        // Simple, finding based on the comment text at the top of the td.ms-formbody where the select's title begins with DisplayName - needed for required columns where title="DisplayName Required Field"
        //   Example: SP2010 <select name="ctl00$m$g_308135f8_3f59_4d67_b5f8_c26776c498b7$ff51$ctl00$Lookup" id="ctl00_m_g_308135f8_3f59_4d67_b5f8_c26776c498b7_ff51_ctl00_Lookup" title="Region Required Field">
        if (columnObj.Type === null) {
            var fieldContainer = findFormField(opt.displayName);
            if (fieldContainer !== undefined) {
                var fieldSelect = fieldContainer.find("select[title^='" + opt.displayName + "'][id$='$Lookup']");

                if (fieldSelect && fieldSelect.length === 1) {
                    columnObj.Type = dropdownType.simple;
                    columnObj.Obj = fieldSelect;
                }
            }
        }

sympmarc wrote Feb 18, 2014 at 2:53 PM

p.s. It would be great if you could validate that this fixes your issue. This is the last bug I was hoping to fix before release.

Thanks,
M.

fairfieldbusserv wrote Feb 18, 2014 at 6:55 PM

Happy to help out. Just arrived at work and grabbed a coffee. Give me 60 mins to download and repoint my scripts and I'll let you know...

fairfieldbusserv wrote Feb 18, 2014 at 7:40 PM

Marc,

Based on a few quick, but representative, tests, BETA2 now displays my related info as expected and I can now no longer recreate the error as I was able to the other day.

Thanks again

Simon

sympmarc wrote Feb 18, 2014 at 8:10 PM

Excellent. I think that's a wrap.

M.

sympmarc wrote Feb 18, 2014 at 8:10 PM

p.s. Thanks...

Homecsiga wrote Mar 26, 2014 at 4:57 PM

Hello Marc,

Could you help me where can I download SPServices 2014.02 Beta? The issue I am facing is the following on SharePoint Online:
I have a Required Field.
In the SPDisplayRelatedInfo function I use it as columnName.
On your samples you showed us the addDollarSigns function where you use #SPDisplayRelatedInfo_Region as a div id if am I right. This works well if my field is not a required field. But if it is the div tag id will be #SPDisplayRelatedInfo_undefined. If I change my field to not to be required the div id will be good again.

Is it handled in the beta release? Could it be downloaded yet?

Anyway, thanks all of your work! It's a great stuff for all SharePoint developer and more on administrators!

sympmarc wrote Mar 28, 2014 at 8:50 PM

Homecsiga:

This discussion was before the 2014.01 release. Things should work in that release.

M.