Fetching Publishing Pages from Pages Library in SharePoint 2010 ECMAScript OM - sharepoint-2010

i want to fetch all the pages in a specific Publishing Web using JavaScript and Client Object Model, it keeps giving
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.
Here's the code,
var selectedDoc;
var ctx = new SP.ClientContext.get_current();
var site = ctx.get_site();
//('created ctx');
//loading the Library
var pagesLib = site.openWeb('/Ar/News').get_lists().getByTitle('Pages');
if (missionType == 'All') {
var query = new SP.CamlQuery();
query.set_viewXml("<View><RowLimit>10</RowLimit></View>");
selectedDoc = pagesLib.getItems(query);
ctx.load(selectedDoc,'Include(Title)');
ctx.executeQueryAsync(getAllNewsWithQuerySuccess(this,this.onListLoadSuccess), getAllNewsWithQueryFailure(this,this.onQueryFailed));

You might be missing a load call. Try this right after you assign pagesLib:
ctx.load(pagesLib);
I'm guessing the error is due to pagesLib not having been populated before you execute the CAML query against it.

You might be missing a load call. Try this right after you assign pagesLib:
ctx.load(pagesLib);
I'm guessing the error is due to pagesLib not having been populated before you execute the CAML query against it.

Related

way to use 'lowdb' in 'express'

Recently, I am trying to make a web page using express, and I am trying to manage login session information and bulletin board data through lowdb.
But when I try to generate and run the code that requires lowdb and controls lowdb,
There is a error with the require syntax with the err_code 'ERR_REQUIRE_ESM'.
When I googled it, it said that it was a syntax compatibility problem between commonjs and ESM, so do I have to convert all other codes to ESM because of one lowdb?
The code below is the code I made to control lowdb.
var low = require('lowdb');
var FileSync = require('lowdb/adapters/FileSync');
var adapter = new FileSync('db.json');
var db = low(adapter);
db.defaults({users:[], topics:[]}).write();
module.exports = db;
I don't want to convert the whole code to ESM because of lowdb, I want to use lowdb through commonjs. Or is there any other good way to handle local db via json file like lowdb?
Use lowdb#1.0.0 and it will work.
npm i lowdb#1.0.0

Get the AccessTier of Blobs

I'm trying to get the AccessTier of blobs. I use the following code snippet:
var blobContainerClient = _blobServiceClient.GetBlobContainerClient("container-name");
await foreach (var blobItem in blobContainerClient.GetBlobsAsync(BlobTraits.All, BlobStates.All))
{
Console.WriteLine(blobItem.Properties.AccessTier)
}
The issue I'm running into is that AccessTier is always null.
I've also tried to get properties explicitly, like:
var properties = blobContainerClient.GetBlobClient(blobItem.Name).GetProperties().Value.AccessTier;
But still it's null. Is there a way to get AccessTier using Azure .NET SDK?
I noticed that the issue is my storage account's type is V1 and in V1 tiers are not supported.

Recent changes to Rally C# REST API?

1) Earlier this week I was able to create defects and testcases using the Create method, which took 2 arguments at the time (a string and the DynamicJsonObject). However now, it needs three. I understand that one of these is now the workspace reference. How do I go about getting the workspace reference? For creating defects and testcases, I am using an empty string, and this seems to be working correctly for me. Is this to be expected?
2) For creating test case results, I am having a bit of trouble.
DynamicJsonObject newTCResult = new DynamicJsonObject();
newTCResult["Date"] = DateTime.Now.ToString("yyyyMMdd");
newTCResult["TestCase"] = "/testcase/11271454106";
newTCResult["Notes"] = "test";
newTCResult["Build"] = "13.1.0.90";
newTCResult["Verdict"] = "Pass";
CreateResult cr = restApi.Create(" ", "TestCaseResult", newTCResult);
As of right now, absolutely nothing is happening when I run this. I was able to do this successfully earlier this week (when I was able to use the Create method with two arguments). I feel that the problem is because I don't have a valid workspace reference. I followed the suggestion of another user in a similar question prior to this which worked for earlier, however now I am having this problem.
I was finally able to resolve this. It appears that the date field needs to be converted to UTC, so my code now looks something like this
newTCResult["Date"] = DateTime.UtcNow.ToString("o");
After making that small change results were working correctly.
It's somewhat surprising that Creates on Stories or Defects work with an empty string for a Workspace ref, although I suspect that on the server-side, the Webservices API is just using Default Workspace for the User of concern.
Either way, here's how you can get a ref to the Workspace of interest:
String myWorkspaceName = "My Workspace";
// Get a Reference to Target Workspace
Request workspaceRequest = new Request("workspace");
workspaceRequest.Fetch = new List<string>()
{
"Name",
"ObjectID"
};
workspaceRequest.Query = new Query("Name", Query.Operator.Equals, myWorkspaceName);
QueryResult workspaceQueryResults = restApi.Query(workspaceRequest);
var targetWorkspace = workspaceQueryResults.Results.First();
Console.WriteLine("Found Target Workspace: " + targetWorkspace["Name"]);
String workspaceRef = targetWorkspace["_ref"];
You can then use workspaceRef in your call to restApi.Create().

IQueryable serialization (web api)

Why isn't this working?:
var surveys = db.Surveys.Where(s => s.Author.UserId == user.UserId);
return from survey in surveys
select new
{
surveyId = survey.SurveyId,
title = survey.Title
};
And this, with a minor change, is?:
var surveys = db.Surveys.Where(s => s.Author == user);
return from survey in surveys
select new
{
surveyId = survey.SurveyId,
title = survey.Title
};
It throws a serialization error
The 'ObjectContent`1' type failed to serialize the response body for content type
'application/xml; charset=utf-8'. (...)
I'm fine with solving it that way, but I have the same error here (below), and can't solve it the same way:
var surveys = db.Surveys.Where(s => s.AnswerableBy(user));
I ran into this issue recently, in my case the problem was that I had circular references created by the Entity Framework - Model First (Company -> Employee -> Company).
I resolved it by simply creating a view model object that had only the properties I needed.
As per the section 'Handling Circular Object References' here on the Microsoft ASP.NET Web API website, add the following lines of code to the Register method of your WebAPIConfig.cs file (should be in the App_Start folder of your project).
var json = config.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
config.Formatters.Remove(config.Formatters.XmlFormatter);
There are separate instructions on that page for dealing with XML parsing.
The exception you are seeing is a general exception, which can be caused by any number of factors. Check the InnerException property of the serialization exception to find out what exactly caused the serialization to fail.
You are using an anonymous object. Make it strongly typed and the serialization will work.
At the end this has to do with Linq to Entities vs Linq to Objects.
Some LINQ queries can not be translated into SQL (like using a method: someCollection.Where(p => p.SomeMethod() == ...)). So they must be translated to memory first (someCollection.ToList().Where...)
I was having the same problem. In my case the error was caused by the relation between tables created in my Dbml file. Once I removed the relation from the DBML file, it worked. I think Database relations can't be serialized.

How do I set a dynamic datasource for ORM?

ORM settings in Coldfusion application.cfc run before anything else runs (onapplicationstart, etc). So how do you set a dynamic datasource (code before the ORM init) in application.cfc? we can set it after and it re-points the ORM to a dynamic datasource, but that requires that the hardcoded datasource must be valid as well. This is tenuous at best.
Here is an example:
<cfscript>
this.name = "someapp_#hash(cgi.http_host)#";
this.ormenabled = "true";
this.ormsettings = { cfclocation = "config/definitions", eventhandling = "true",datasource="STATICDATASOURCE" };
</cfscript>
If it's not specified in application.cfc scope then you get errors like "ORM is not configured for the current application."
We need to be able to get the datasource from a text file on the server.
this.datasource="YourDatasourceName";
Well, if you wanted to store a file, for this example we'll call it "datasource.xml" consisting of:
<dataSourceName>Name goes here</dataSourceName>
You can read it in with:
dataFile = fileRead("pathToFile/datasource.xml");
data = xmlParse(dataFile);
dataSourceName = data.dataSourceName.xmlText;
this.datasource=dataSourceName;
ORM datasource just uses the default datasource if not defined.
Having said that, if you want to add / remove datasource dynamically, see Administrator API at: http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf364104-7fcf.html (available since CF8)
I'm not sure if you can re-set the this.ormsettings.datasource to something else at runtime (i.e. onApplicationStart()? or onServerStart()?), but many of the settings can be set again. You may want to try it out.