2

I am trying to get the onQuickLaunch flag from a SP.List using javascript. I am able to get other list attributes, however when I try to execute

list.get_onQuickLaunch();

I get an error

Uncaught Error: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

Below is my code, I started traversing down to the quickLaunch object hoping it would help me, but it doesn't look like it has.

ctx = SP.ClientContext.get_current();
web = ctx.get_web();
nav = web.get_navigation();
ql = nav.get_quickLaunch();
list = web.get_lists().getByTitle('Hey');

ctx.load(web);
ctx.load(nav);
ctx.load(ql);
ctx.load(list);
ctx.executeQueryAsync(function() {
  console.log('done'); 
  console.log(list.get_onQuickLaunch());
});
1

This error occurs due to OnQuickLaunch property is not initialized for SPList object on the client side.

It means that not all properties are retrieved for List by default.

In order to retrieve additional properties it should be specified explicitly. So, for the current example the line:

ctx.load(list);

should be changed to this one:

ctx.load(list,"OnQuickLaunch");

After that property OnQuickLaunch could be retrieved using get_onQuickLaunch() function

0

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.