This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Need HELP on Filtering

didonato - Monday, September 19, 2016 12:38 PM:

Normal 0 false false false EN-US X-NONE X-NONE

I have a filter setup so that it displays data based on another field. The filter works fine, but now I have been tasked to filter on two fields. The original filter needed to go to a Relationship table to retrieve its data, the new filter field can filter directly on the result of the first filter. The Highlighted area is what I added to the original filter, now I’m stuck.

Normal 0 false false false EN-US X-NONE X-NONE

///<SUMMARY>

///On Select Software, if there is a Model defined, only display Software defined as relationship in selected Model

///</SUMMARY>

 

///Get value from the source field///

var itm = inArgs.itemContext;

var model_id = top.aras.getItemProperty(itm,"model");

 

/// this is the new field I need to filter on///

var product_id = top.aras.getItemProperty(itm,"product");

 

if (!model_id){

                return;

}

 

///Select Relationship table to filter on source_id = model///

var softwareList = this.newItem("MIN_Model_Software_Catalog","get");

softwareList.setProperty("source_id",model_id);

softwareList = softwareList.apply();

 

///Store related_id’s in a Array///

var idArray = new Array();

for(var i = 0; i < softwareList.getItemCount() ; i++){

                idArray.push(softwareList.getItemByIndex(i).getProperty("related_id"));

               

}

 

///Filter Data///

inArgs.QryItem.item.setAttribute("idlist",idArray.join(","));

return("");

 

This is the result of the first filter. I  know need to filter on the highlighted

Normal 0 false false false EN-US X-NONE X-NONE

 

PRODUCT
MODEL
RELEASE
48F18D2A6EF04FF2A4CFF1E3CB8363BA
E05BD9A92D5D48C0895470EBC9B6EB71
In House Approved
48F18D2A6EF04FF2A4CFF1E3CB8363BA
E05BD9A92D5D48C0895470EBC9B6EB71
In House Approved
214B7B19203A47F2951010CDB8F2A48F
E05BD9A92D5D48C0895470EBC9B6EB71
In House
214B7B19203A47F2951010CDB8F2A48F
E05BD9A92D5D48C0895470EBC9B6EB71
In House
Normal 0 false false false EN-US X-NONE X-NONE
RELEASE

 

Normal 0 false false false EN-US X-NONE X-NONE

 



edonahue - Friday, September 23, 2016 4:36 PM:

Hi Didonato,

I'm not sure I understand your use case. Where are you trying to display the filtered results? Could you provide some more detail on the result you are trying to achieve?



didonato - Saturday, September 24, 2016 1:08 PM:

Eli, Thank you for replying. I can't get this to work. I think it's a simple solution that I'm over thinking. I created a JPG that explains my problem and shows images, but I can't get the "File Attachment" to work in this Forum. Is there any way I can email you the information? I REALLY appreciated if you can. My email is [email protected]

 

Thanks!!!

 



didonato - Saturday, September 24, 2016 1:08 PM:

Eli, Thank you for replying. I can't get this to work. I think it's a simple solution that I'm over thinking. I created a JPG that explains my problem and shows images, but I can't get the "File Attachment" to work in this Forum. Is there any way I can email you the information? I REALLY appreciated if you can. My email is [email protected]

 

Thanks!!!

 



edonahue - Monday, October 10, 2016 4:29 PM:

Hi didonato,

Can you try re-uploading the image? I had the IT team fix the file attachment issue. If that doesn't work, you can email in to [email protected].



edonahue - Wednesday, October 12, 2016 6:01 PM:

Hi Didonato,

Based on the image you provided, it looks like you are trying to set up a list < filter list < filter list configuration. The Aras client only supports list - filter list pairs out-of-the-box, but there is an Aras Labs project on Github that may help you with your use case. The project is called Cascading Filtered Lists: 

https://github.com/ArasLabs/cascading-filtered-lists 

For reference, I'm also including the image you provided:



didonato - Thursday, October 13, 2016 7:55 AM:

Eli,

I don't think that would work.

I need to filter"Software Version" based on the value of two fields "Product" and "Model". Right now it's only filtering from the value of "Model" I need  it to also include the value of "Product". If you look at the attached image (bottom left) you can see that when I select "Software Version" it only displays that value filtered from Model "E05BD9..) I need it to also filter on the selection of "Product 214B7B.."  So basically I need to edit my "MIN_FilterSoftwareByModel" Method to include the value of "Product"

These are not "List" or "Filter List" Types, they are "Item Types"

THANK YOU Eli!!

 

 



edonahue - Monday, October 24, 2016 5:44 PM:

Ah, thanks for the clarification. Do your MIN_Model_Software_Catalog items have a relationship or property that relates them to the products that you need to filter on? That is, how does your data model connect products and software versions? Once you've determined that, you can modify the MIN_FilterSoftwareByModel method to filter software versions by model AND product.

Here's the pseudocode:

// get the model_id from the context item (done)

// get the product_id from the context item (to do)

// build a query for software version items (1/2 done)

    // filter source_id using model_id from context (done)

    // filter property/relationship using product_id from context (to do)

// apply query to get results from the server (done)

// populate software version droplist (done)

Does this make sense?



didonato - Tuesday, October 25, 2016 7:46 AM:

Eli,

Yes, it does make sense, I added the "get the product_id from the context item" but unfortunately I don't know how write the code to pass these two values to filter

the "MIN_Model_Software_Catalog". I'm not fimilar with programming and can't find any examples to help me. Just wondering

if someone has any examples. I know I'm close - Thanks!!

**************************************************************************

var itm = inArgs.itemContext;

// get the product_id from the context item (done)
var product_id = top.aras.getItemProperty(itm,"product");

// get the model_id from the context item (done)
var model_id = top.aras.getItemProperty(itm,"model");

if (!model_id){
    return;
}

// filter property/relationship using product_id from context (to do)   (*** I'm not sure how to code this *****)
var softwareList = this.newItem("MIN_Model_Software_Catalog","get");
softwareList.setProperty("source_id",model_id);
softwareList = softwareList.apply();

var idArray = new Array();
for(var i = 0; i < softwareList.getItemCount() ; i++){
    idArray.push(softwareList.getItemByIndex(i).getProperty("related_id"));
   
}
inArgs.QryItem.item.setAttribute("idlist",idArray.join(","));
return("");



edonahue - Tuesday, October 25, 2016 4:52 PM:

Hi didonato,

The code syntax depends on how your data model is defined. Are the MIN_Model_Software_Catalog items related to product items by an item property or by a relationship item (form tab)?



didonato - Wednesday, October 26, 2016 7:10 AM:

They are related by an item property



edonahue - Wednesday, October 26, 2016 9:54 AM:

Hi didonato,

Then you would set the filter using setProperty(), just like you did with model_id.

// filter property/relationship using product_id from context (to do)
var softwareList = this.newItem("MIN_Model_Software_Catalog","get");
softwareList.setProperty("source_id",model_id);
softwareList.setProperty(<PROPERTY NAME>,product_id);
softwareList = softwareList.apply();



didonato - Wednesday, October 26, 2016 6:34 PM:

Hi Eli,

So I'm getting the values of Product_id and Model_id back correctly.

Product_id =AA (this comes context item call Product on the form) *Done*

Model_id = A10,B20,C30 (This comes from the Array created below) *Done*

Right now only the values of the array (model_id) are filtering the Item.

I need to include the value of (product_id) also, so in the example below only the first two item would be correct.

Product             Model

AA                    A10

AA                    B20

BB                    C30

 

 

 

 

var itm = inArgs.itemContext;

// get the product_id from the context item (done)
var product_id = top.aras.getItemProperty(itm,"product");

// get the model_id from the context item (done)
var model_id = top.aras.getItemProperty(itm,"model");

if (!model_id){
    return;
}

// filter property/relationship using product_id from context (to do)   (*** I'm not sure how to code this *****)
var softwareList = this.newItem("MIN_Model_Software_Catalog","get");
softwareList.setProperty("source_id",model_id);
softwareList = softwareList.apply();

var idArray = new Array();
for(var i = 0; i < softwareList.getItemCount() ; i++){
    idArray.push(softwareList.getItemByIndex(i).getProperty("related_id"));
   
}
inArgs.QryItem.item.setAttribute("idlist",idArray.join(","));
return("");



edonahue - Thursday, October 27, 2016 11:31 AM:

Hi Didonato,

Your method isn't filtering on product yet because you need to update the query that gets the MIN_Model_Software_Catalog items. The code below gets MIN_Model_Software_Catalog items that are related to the model_id item and have an item property set to product_id. You will need to replace the highlighted value with the item property on MIN_Model_Software_Catalog with product as a data source.

// filter property/relationship using product_id from context (to do)
var softwareList = this.newItem("MIN_Model_Software_Catalog","get");
softwareList.setProperty("source_id",model_id); 
softwareList.setProperty(<PROPERTY NAME>,product_id);
softwareList = softwareList.apply();



didonato - Thursday, October 27, 2016 11:53 AM:

Eli,

They are seperate, the model_id filters the MIN_Model_Software_Catalog item and the product_id already has

a value from the field in the form "product" (This was already selected in the form). I now need to take the values of these two and filter on the item "Software" from the form.

 

THANKS

 



edonahue - Thursday, October 27, 2016 2:13 PM:

Hi Didonato,

The sample code I provided shows how to filter Software items based on the selected model_id and product_id. In this context, we are using this.newItem to build a query for MIN_Model_Software_Catalog items (softwareList). By using setProperty() on softwareList, we are setting the criteria we want to use in our query. This sample code does not modify the context item (form item).

This js code:

 

// filter property/relationship using product_id from context (to do)
var softwareList = this.newItem("MIN_Model_Software_Catalog","get");
softwareList.setProperty("source_id",model_id); 
softwareList.setProperty(<some_property>,product_id);
softwareList = softwareList.apply();

 

creates this AML query to send to the server:

 

<AML>
  <Item type="MIN_Model_Software_Catalog" action="get">
    <source_id>value of model_id</source_id>
    <some_property>value of product_id</some_property>
  </Item>
</AML>

 

The result should be MIN_Model_Software_Catalog items with source_id=model_id and some_property=product.



didonato - Tuesday, November 1, 2016 4:18 PM:

Thanks Eli, that worked!!  If ur ever in Philly, I owe u a beer.