Most efficient way to join data from two views - xpages

Folks:
I have recently begun working with xPages. I have a view of documents that needs to present data from other related documents in six separated columns. What I am trying is to use a Computed column that does a lookup to a view with a concatenated string. My intention was to parse this into the 6 columns of data. It isn't working and it may be silly of me to try referring to a computed column in another computed column.
Another alternative was to have the underlying view present the UNID of the other document and then do a #GetDocField on the xPages view.
So I have two questions:
1) May I programmatically refer to a Computed column in a view from another Computed column?
2) For efficiency, what would be the best way to present data like a 'join' in a view?
I appreciate your attention and help.
Cheers,
John Collis

Can you try to “go native” ? You build one view that contains both documents arranged to be in that view after each other. So you have Type1,Type2,Type1,Type2 etc.
Then use a repeat control to render a table or list “joining” the two rows.
This would save you doing tons of lookups.
Eventually you use that view as Json Rest source to do the joining in Json

I would create a Java bean that returns a list of Java objects that contain your data.

Related

Concatenated SQL fields in selector and/or custom PXDimension

We have a set of BLC/DAC for a customization that has multiple tables with the given relationship
Table1 - T1ID (int-autoincrement), T1CD (char-substitute key)
Table2 - T2ID (int-autoincrement), T2CD (char-subsitute key), T1ID (reference to T1ID)
where the records in Table2 are unique for each given T1ID selected.
The initial design specification was for the users to select first the Table1 value, then the Table2 value (UsrTable1Value, UsrTable2Value respectively) in the data entry screens.
The users have recently asked if it's possible to combine these into one field simular to a Dimension selector so that there is one field resulting in "Table1-Table2" stored as T2ID.
My first thought was to simply create a subclassed dac with a concatenated property for T1CD-T2CD and base the substitute key off that however performance is a problem when that is done (1.6 million records). The delay is in the framwork side as it appears it processes the entire recordset when generating the concatenated substitute key.
Based on that I thought perhaps instead to simply generate a PXDimension configuration for this however I can't find any reference to make Dimension 2 rely on the value of Dimension 1.
I know i could always create a view that does this but i'd prefer to keep it within the framework if possible.
That basically brings me to two questions
1) Outside of a view, is there way to concatenate fields in the BQL so the lifting is done on the SQL and not with a calculated property?
2) Does anyone have or know of a sample of custom Dimensions where the values in level 2 depend on the value in level 1?
Any suggestions would be appreciated.
Out of the box, dimension selectors are designed to work only with Segmented Keys and won't be able to handle values from multiple tables. In theory, it can be possible to populate segment popup from different tables within a custom DimentionSelectorAttribute. However, this will additionally require to store each T1ID/T2ID pair in a separate table with some other column declared as a key (same concept used in the Sub table to store sub accounts: SubID is a key and SubCD stores values composed from multiple segments).
My personal opinion, the effort is just not worth it. Going one step further, I would check with the customer on how they expect navigation buttons (first, prev, next, last) to work with their segmented input control? If following standard Acumatica UI design with separate input created for every key field, no additional effort is needed to properly handle both data entry and navigation.

How to create a view using a count of certain field

I am trying to create a categorized view of all Notes documents that have a field with exact same value, i.e. there is a field for Contractor Name and I want to create a view that lists each Contractor and the documents that relevant to each. How do I do this? I have tried view formulas like the following but no success as yet
SELECT #IsAvailable(Contractorid) & #Count(Contractorid) > 1
SELECT #Count(#IsAvailable(Contractorid)) >1
Nsf databases are no relational databases. The count of different documents with a unique value in a specific field cannot be used to build a view selection formula.
You could write an agent, that runs through all documents and counts them and puts all with count > 1 in a folder, but this is quite a lot of LotusScript code and needs some advanced knowledge.
The other possibilit would be to categorize the view by ContractorId and add one column before that categorized column: simply use 1 as column formula and select "display totals" in the column properties as well as "hide details".
Then at least you have the information, how much documents are in each category, but unfortunately you cannot filter by it and you cannot sort by this column.
A third possibility would be to use an xpage interface, but that is even more work to do and a completely different story developmentwise.
This is similar to view to identify duplicates. My approach is to use folder.
Make a new folder with design of your view. Instead of (not working) selection formula use short LS code as an action, or QueryOpen event (make sure only one user runs the script).
The code should cooperate with another (hidden) view sorted by Contractorid. Make a ViewNavigator for that view and traverse through it with simple logic - if previous entry has the same Contractorid as the current one, put both documents into folder**. That way you will get list of all documents with duplicate Contractorid. Make sure to wipe all the current content from the folder at the start.
** This can be optimized further by slightly more complicated algorithm to handle first duplicate diferently - for more than two duplicates this algorithm makes extra calls of PutInFolder method.

Filtering a repeating table linked to a secondary datasource

I have an infopath form based on a sharepoint list (worktracker).
In that form there is a repeating section which holds data from a secondary source which is the worktracker list again.
I would like to filter that table using the value in a field on the form - this enables me to run a check on duplicate items on the list by using a calculated checking reference.
I have done this by using conditional formatting to hide the non-matching items but that this killing my form as IE throws tantrum as it takes too long.
Does anyone know another way to do this? I am stuck using IE8 - not my choice!
UPDATE:
So since posting the above, I had since tried using a REST connection which doesn't work as my list is too big. I have also tried using an XML connection to a filtered view and that didn't work either!
Cheers,
In the form, select the value field. Create a rule that sets the secondary data source's query field of the same name to that value. Then query the secondary data source. It will only return the items where the value matches.

tag count on collection

I want to copy feature from stackexchange sites: every time you have list of questions, on the right side there is a list of all tags presented in them, including their count (frequency).
Is there any performance friendly way, how to obtain this kind of information without iteration through every element in view? Let's suppose it should work with common view data source, and content of the view can be altered by filter (keys, category) or fulltext.
I have already have considered (and refused) few solutions:
Iterate through collection - unusable for performance reasons (especially if ViewNavigator can't be used - FT query).
Counting tags in rendered content - limited to visible page only, tags for other pages are not counted (stackexchange counts tags for every page). Good performance though.
DocumentCollection.intersect - iteration through all tags and intersecting collections of all documents with that tag against source collection would result in count of documents with such tag. This approach is performance killer.
You could use a categorized view with a summary column and query it in json. Needs to be collapsed. ?ReadViewEntries&Outputformat=json
I would consider two basic approaches:
Store the tags in a multi-value summary text field in your question documents, create a categorized view based on that field, open the view, create a NotesViewNavigator, use CreateViewNavFromCategory to create a NotesViewNavigator that only contains the documents that match the tag, and get the NotesViewNavigator.count() property value.
Store the tags in a field (it can be multi-valued or single-valued, summary or non-summary text or even a rich text field) in your question documents, full text index the database, and use the Database.FTSearch method with a search formula that uses the FIELD keyword to get a NotesDocumentCollection, and use the NotesDocumentCollection.count() property.
For filtering, I think the latter approach may be better. You might be able to just revise your FT query to include additional conditions to accomplish the filtering. This could be very flexible, and should be pretty fast. With NotesViewNavigator, on the other hand, you would have to iterate through the NotesViewEntry objects in order to do the filtering.

Performing join between document library and list

I have a document library where i have columns called Title and Category(is a lookup field) and User.Also,I have a list where i am just storing categories. I would like to join both document library and list so that i can dispaly all categories and the documents associated with it. once i get everything i would like to perform filtering so that it dispalys only selected user's documents.The displaying of the documents is working fine but not filtering. My questions is CAn we perform join between doc library and list? Plesae help me.
Thanks
The content query web part (CQWP)is probably the easiest way to do this without code. Since you only have one field in your lookup (categories) you don't need to do a join as SharePoint stores the lookup value in the Document Library. You will need to edit your CQWP to add this field, there is a good tutorial on doing this here. It also explains how to filter your CQWP.
Finally you will need to clean up your lookup field as SharePoint will store the value like this: 1;#Category1.
The CQWP uses XSLT to display the results so in your case you probably don't want to show 1;#Category1 you probably only want to show Category1. You can use the following XSLT to accomplish this:
<xsl:value-of select="substring-after(#Name_Of_Your_Lookup,'#')"></xsl:value-of>

Resources