2

Closed

API change for roboCAML.Query

description

In it's current form, creating queries can be a bit convoluted. Here's an example:
 
                    camlQuery = "<Query><Where>" +
                                                roboCAML.Query({
                                                    listName: "SomeListName",
                                                    config:
                                                    [
                                                        {
                                                            filter: "&&",
                                                            op: "=",
                                                            staticName: "ListUID",
                                                            value: ListID,
                                                            LookupId: true
                                                        },
                                                        {
                                                            filter: "||",
                                                            op: "=",
                                                            staticName: "Status",
                                                            value: Statuses[STATUS_SELECTED],
                                                            LookupId: true
                                                        },
                                                        {
                                                            filter: "||",
                                                            op: "=",
                                                            staticName: "Status",
                                                            value: Statuses[STATUS_EVAL],
                                                            LookupId: true
                                                        },
                                                        {
                                                            op: "=",
                                                            staticName: "Status",
                                                            value: 0,  //Handles the none option
                                                            LookupId: true
                                                        }
                                                    ]
                                                }) +
                                            "</Where></Query>";
 
With the Query working as is, it leaves a lot to be desired.
 
Proposed change:
Add defaults to roboCAML. These will default the query to be wrapped automatically with <Where> & <Query> tags. If default is set to Client OM, the query will be adjusted accordingly.
 
Add an OrderBy property. This should accept a simple array like you would normally use or the full roboCAML.OrderBy() call.
Closed Jun 18, 2012 at 7:54 PM by iOnline247
These items have been tested and verified to work.

comments

jbhoward wrote Dec 14, 2011 at 1:32 PM

I think you need an option to determine whether it will be returned "closed" or not. The default would be "open," meaning you could build a CAML snippet that could be re-used. Then, in conjunction with my other API update suggestion, the user could add a 'close: true' to the Query object to close it off with the <Query><Where> wrap (and an optional <OrderBy>.

Example:
camlQuery = roboCAML.Query({
listName: "SomeListName",
close: true,
orderBy: orderByVar || roboCAML.OrderBy(),
config:
[
    { filter: "&&", caml: camlSnippetVar || roboCAML.Query() },
    { filter: "||", op: "=", staticName: "Status", value: Statuses[STATUS_SELECTED], LookupId: true },
    { filter: "||", op: "=", staticName: "Status", value: Statuses[STATUS_EVAL], LookupId: true },
    { op: "=", staticName: "Status", value: 0, //Handles the none option LookupId: true }
]
});

wrote Dec 14, 2011 at 1:35 PM

wrote Feb 14, 2012 at 7:26 PM

wrote Jun 18, 2012 at 7:54 PM

wrote Feb 13, 2013 at 6:22 PM

wrote May 16, 2013 at 2:43 AM