StratusForms
StratusForms copied to clipboard
data-StratusFormsLookup
Can some one send me an example or explain how the query works in the lookup?
I am trying to show only records that meet a condition.
I figured out the correct CAMLQuery to get the result set I want, but passing it from the HTML page is causing issues:
<select id="SQUADRON" listFieldName="SQUADRON" size="10" multiple data-StratusFormsLookup="{listName:'LU_COUNTRIES',fieldName:'Title' , query:'"<Query><Where><Neq><FieldRef Name='Title'/><Value Type='Text'>Belgium</Value></Neq></Where></Query>";'}">
I get Unterminated string constant error message. The only way I can get it to pass is to remove all the ' and " but then get no result set back. So there must be something that I need to do, but not sure. Any help would be great
OK weird, works query works fine on new entry, but on a edit/update the query is not being used. Any suggestions????
I think I found the issue:
//utility function to load a drop down list with values from a SharePOint List $.fn.StratusFormsLoadDDL = function (options) {
var opt = $.extend({}, {
webURL: "",
query: "",
listName: "",
firstOptionText: "Please Select",
fieldName: "Title",
orderByField: "Title",
selValue: "",
completefunc: null
}, options);
var $this = this;
return this.each(function () {
var curValue = $($this).find("option:selected").text();
$($this).empty();
$().StratusFormsLoadDropDownList(this, curValue, opt.webURL, opt.query, opt.listName, opt.firstOptionText,
opt.fieldName, opt.orderByField, opt.completefunc,opt.selValue);
});
};
This sets the query back to "", which is a problem.
Any suggestions how to fix as this is in the stratus-Forms-1.5js file
Just tried 1.55 same result, it is not passing the query when you load a record, only for new
OK wow..... found the fix
In stratus-forms-1.55a.js the call on line 727, the following attribute was left off
query: lookupInfo.query,
So if you add that, see below now the query is passed on record load.
if ($(element).attr("data-StratusFormsLookup") != undefined ) {
eval("var lookupInfo=" + $(element).attr("data-StratusFormsLookup"));
var thisLookup = $(element);
var selectValue = htmlDecode(value);
$(element).StratusFormsLoadDDL ({
listName: lookupInfo.listName,
webURL: lookupInfo.webURL,
firstOptionText: lookupInfo.firstOption,
orderByField: lookupInfo.orderByField,
fieldName: lookupInfo.fieldName,
query: lookupInfo.query,
selValue: selectValue,
completefunc: function(elem,selValue) {
Haha I just came across this problem today. You'll also need to do a little more beyond this part, the function that does the lookup only populates the orderBy if the query is blank, so you may wish to also include the orderBy for the query != "" condition. (if you intend to make use of the orderByField).
Something like this in data SPServices:
if (query == "") {
query = "<Query><Where><Neq><FieldRef Name='ID'/><Value Type='Integer'>0</Value></Neq></Where><OrderBy><FieldRef Name='" +
orderByField + "'/></OrderBy></Query>";
} else if (orderByField != "") {
query = "<Query><Where>" + query + "</Where><OrderBy><FieldRef Name='" + orderByField + "'/></OrderBy></Query>";
}
I am trying to filter down records also.
Were you able to get this working?
here is the base lookup: data-StratusFormsLookup="{listName:'MNGWPD Facilities',firstOption:'Select DisposalLocation1',fieldName:'ActiveLookup'}"
Here is my CAML: <Where><Eq><FieldRef Name="Facility_x0020_Status" /><Value Type="Text">1</Value></Eq></Where>
I was trying some like this: data-StratusFormsLookup="{listName:'MNGWPD Facilities',firstOption:'Select DisposalLocation1',fieldName:'ActiveLookup',query:'I think caml goes here'}"
But I can't seem to encode it correctly, if this is how I should filter the control.