0

One day, I had just read one topic [SharePoint 2013: Using WPQ2FormCtx to read list item information]- which holds plenty of useful information and I applied one in my code and it works perfectly.

And boom right now, my page went dead. I don't know why and I start tracing and debugging my code on my custom webpart. The "WPQ2FormCtx" object doesn't exist in my source anymore, it changed to WPQ3FormCtx.

Any one have an idea about this? I wonder if Microsoft updated some stuff.

Can anyone give me a clue, a way to get the name of this object? Or the way you used to read list item information?

Have a nice day
Thanks

0

I found out about this a month ago and these values are subject to change.

What you can do instead is to loop over a certain number of WPQ you might want and return the first one or one that has the correct identifiable context.

To get around this problem you can do:

function getdata() {
  var ctx = {};

  for (var iCtx = 0; iCtx < 12/*whatever number u think is needed */; iCtx++) {
    if (typeof window['WPQ' + iCtx + 'FormCtx'] !== 'undefined') {
      ctx = window['WPQ' + iCtx + 'FormCtx'].ListData;
      ctx.Id = window['WPQ' + iCtx + 'FormCtx'].ItemAttributes.Id;
      break;
    }
  }

  return ctx;
}

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.