0

I am having an issue when using the displayFormat: "none" with SPDisplayRelatedInfo.

My plan is to populate fields on the new and edit forms with the data from the selected lookup item.

When I set displayFormat to "list" or "table" it's working. The little div is inserted in the form and presents the "related info".

I am using the completefunc option and want to pass the data into a function so I can populate the appropriate fields.

But no matter what the xData and Status are undefined. I read somewhere setting the displayFormat to "none" and passing the data to the completefunc would be the way to go but I'm having no luck with that.

Any insight is appreciated.

  • You should add your code to your question. – Christoffer Feb 20 at 19:17
0

This appears to be a bug in SPServices. The impetus for adding displayFormat: "none" to SPDisplayRelatedInfo in SPServices was a blog post by Mikael Svenson titled Using SPServices to help populate fields in a SharePoint form. In the post he describes how he extended SPServices.SPDisplayRelatedInfo with displayFormat: "none".

Later, Marc Anderson added it to SPServices. Mikael mentioned in the related GitHub issue that the xData structure needs to be passed to completefunc, but it doesn't look like that was done. From SPServices v2014.02, the function showRelated ends with:

// If present, call completefunc when all else is done
if (opt.completefunc !== null) {
    opt.completefunc();
}

i.e. no arguments are passed to your completefunc.

It wouldn't be that hard to fix. The call back to your completefunc needs to be moved up a couple of lines so it's inside the internal completefunc (right now it's at the end of showRelated, which means that it gets called before the async operation is actually completed), and then pass xData to it.

BTW, this is fixed in SPServices 2.0, but that's currently in pre alpha status. Still, you could look at the source code for SPDisplayRelatedInfo if you don't understand my description of the fix. He's basically done exactly what I describe above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.