You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have four lists, Regions, Customers, Products and Orders. The Orders list is where all the roads meet.
An order includes a Region field as lookup into the Regions list, a Customer Name field which is a lookup into the Customers list and a Product Number field which is a lookup into the Products list. In addition it inludes an Current Order field and a Previous Order field which is a lookup into this Current Order field.
Each Customer is assigned to a region (lookup field into Regions). Each customer can have several product numbers and each product number might be assigned to (bought by) different customers.
Now my aim is:
to ensure that my Previous Order numbers displayed are really restricted to the same customer and the same product number. So I would like to filter the Previous Order entries based on Customer Name and Product Number.
My according JS code is below. I use jQuery 3.6.0 and SPServices 2014.02.
Now here is my problem:
Loading my [custom] NewForm will deliver the result I wish for. Customer Names are filtered based on selected Region, Product Numbers are filtered based on selected Customer Name and Previous Order numbers are filtered based on Customer Name AND selected Product Number.
If I keep the Region and Customer Name and change the Product Number then the Previous Order filter list gets populated correctly and works as intended.
However, once I start changing any of the other values (Customer Name or Region [incl. the automatically following downstream cascade]) it does not filter as intended. It seems that script keeps using the same Customer Name for filtering - which breaks the code/filter.
My question is:
Can anybody tell how I need to adjust my code to fix the problem and achieve the result described above?
var myJQ = jQuery.noConflict(true);
var sCamlQuery = "";
myJQ(document).ready(function() {
myJQ().SPServices.SPCascadeDropdowns({
relationshipList: "Customers",
relationshipListParentColumn: "Region",
relationshipListChildColumn: "Customer_x0020_Name",
parentColumn: "Order Region",
childColumn: "Customer Name",
completefunc: function() {
alert('Filter customer based on region');
},
debug: true
});
myJQ().SPServices.SPCascadeDropdowns({
relationshipList: "Orders",
relationshipListParentColumn: "Customer_x0020_Name",
relationshipListChildColumn: "Product_x0020_Number",
parentColumn: "Customer Name",
childColumn: "Product Number",
completefunc: function() {
sCamlQuery = "<Eq><FieldRef Name='Customer_x0020_Name'/><Value Type='Text'>" + $("input[Title='Customer Name'], select[Title='Customer Name Required Field']").find("option:selected").text() + "</Value></Eq>";
},
debug: true
});
myJQ().SPServices.SPCascadeDropdowns({
relationshipList: "Orders",
relationshipListParentColumn: "Product_x0020_Number",
relationshipListChildColumn: "Current_x0020_Order_x0020_no",
parentColumn: "Product Number",
childColumn: "Previous Order",
CAMLQuery: sCamlQuery,
completefunc: function() {
var value = $("input[Title='Customer Name'], select[Title='Customer Name Required Field']").find("option:selected").text();
alert('Filter Previous Order based on product number');
alert('Field value is ' + value + '.');
alert('sCamlQuery value is ' + sCamlQuery + '.');
},
debug: true
});
});
The text was updated successfully, but these errors were encountered:
Sorry I didn't see your question sooner. You may well have already solved this.
The way you have your code set up, the relationships are:
Customer -> Region, CustomerName -> ProductNumber, and ProductNumber -> CurrentOrderNo
But since the latter two are both coming from Orders, there is undoubtedly not a hierarchical relationship to those two.
Instead, I would expect something based on the relationships in the three lists: Regions, Customers, Products
I have four lists,
Regions
,Customers
,Products
andOrders
. TheOrders
list is where all the roads meet.An order includes a
Region
field as lookup into theRegions
list, aCustomer Name
field which is a lookup into theCustomers
list and aProduct Number
field which is a lookup into theProducts
list. In addition it inludes anCurrent Order
field and aPrevious Order
field which is a lookup into thisCurrent Order
field.Each Customer is assigned to a region (lookup field into
Regions
). Each customer can have several product numbers and each product number might be assigned to (bought by) different customers.Now my aim is:
to ensure that my
Previous Order
numbers displayed are really restricted to the same customer and the same product number. So I would like to filter thePrevious Order
entries based onCustomer Name
andProduct Number
.My according JS code is below. I use
jQuery 3.6.0
andSPServices 2014.02
.Now here is my problem:
Loading my [custom] NewForm will deliver the result I wish for.
Customer Names
are filtered based on selectedRegion
,Product Numbers
are filtered based on selectedCustomer Name
andPrevious Order
numbers are filtered based onCustomer Name
AND selectedProduct Number
.If I keep the
Region
andCustomer Name
and change theProduct Number
then thePrevious Order
filter list gets populated correctly and works as intended.However, once I start changing any of the other values (
Customer Name
orRegion
[incl. the automatically following downstream cascade]) it does not filter as intended. It seems that script keeps using the sameCustomer Name
for filtering - which breaks the code/filter.My question is:
Can anybody tell how I need to adjust my code to fix the problem and achieve the result described above?
The text was updated successfully, but these errors were encountered: