Using Relational Controls, how do you do a "soft" delete - xpages

In the relational controls sample db (xpagesjdbc.nsf) there is an example called JDBC_RowSetDatasource. This uses a view panel and has the check box turned on in the view panel to allow the user to select a document. Then there is a button to delete the selected docs using a simple action, delete selected documents. This deletes the document but until the button with the code that has jdbcData1.acceptChanges() is pressed the changes are not committed and the row shows as to be deleted (first icon column with the isRowDeleted() call to determine the icon).
I am working on a similar situation but with a repeat control. I can delete the row with #jdbcDelete but that is immediate. Looking at the data it shows the row is gone from the data even before acceptChanges() is called.
Since I can't use the simple action to delete selected documents (no view panel) what is the Java equivalent to delete the row in a similar manner? I have tried deleteRow() on both the variable for the data set and for the row but get an error in both cases.

Howard, the simple action just memorizes the primary keys of the records as to be deleted. If you want to simulate that you need to take a similar approach (using a ViewScope variable or bean) to keep track of your "deleted" records and a method that executes the actual deletion.
Smells like a case for a bean

Related

Xpages chained djFilteringSelect in separate dialogs

I am trying to make a 2nd djFilteringSelect using a #Dbcolumn depending on the value selected in the 1st djFilteringSelect control. That's a common task, using a partial refresh. However, each of the controls is within a dialog control from the extension library. One dialog pops up, the user selects a value, and automatically the 1st dialog closes and the 2nd opens. YOU CAN'T SEEM TO REFRESH THE FIELD (I'm guessing b/c it's not in the DOM). I've tried writing the first value to to an computed field and/or a text box on the main Xpage using CSJS and then looking for that value for the second lookup. Also, tried with SSJS, etc. I tried do updates and writing to fields on either the onChange or on the click of button. How do I go about using the selected value of the first to do the lookup in the 2nd?
You can use a single dialog control where you hide and show the relevant controls. I am using this approach in several apps.

VBA Listbox not updating to reflect new source list when called from itself

Edit:
Playing around further, it seems that you can't assign a new array to a listbox via the .list=somelist approach when the assignment happens in response to a click on the listbox itself. Or rather, you can assign the list, but it simply won't visually populate the listbox...although Excel seems to think it's there.
The .additem or .removeitem methods do however result in a visual change when called from a listbox click, which means you have to build your new array up that way I guess. How tedious.
You can however feed a listbox an entirely new array using the .list=somelist approach via a CommandButton-initiated action. But the user has to obviously click a button to do this. Which in my case below defeats the purpose.
Edit Over.
I'm designing a UserForm to help filter PivotTables. It's a cross between the existing Pivot Filter functionality and a Slicer. Here's what you see if you double-click on a PivotField header:
Note the Search field at the top, and the three buttons immediately below that search field. If you type something into that field, then instead of displaying everything that's currently filtered, you instead get a list of any matches, and you can then apply those search results to the underlying PivotTable via those three CommandButtons. The first cb simply filters the PivotTable to reflect the search, and the other two let you add or remove any search result from an existing filter.
I want to do away with those three command buttons, and instead (in the event that a search is performed) simply list those three options at the top of the ListBox above any search results returned. Clicking on those three options will then trigger the exact same code as currently triggered by the Command Button.
Here's how that looks currently if I actually type something in that Search box (Note I haven't yet removed the three command buttons this does away with from that Search frame):
I've added a simple bit of code to the lbResults_Change() event handler that checks if a user clicks any of those first three options. All that code does is trigger the exact same routines as would be triggered if they'd simply clicked on the actual command buttons themselves:
For i = 0 To 4
If Me.lbResults.Selected(i) Then Exit For
Next i
Select Case i
Case 0: cmdApplySearch_Click
Case 1: cmdAddToFilter_Click
Case 2: cmdSubtractFromFilter_Click
Case 3: Me.lbResults.Selected(3) = False
End Select
Here' the problem: The listbox gets updated just fine if I click on those command buttons, as you can see from the below. The Pivot has been filtered accordingly, and those contextual search options have been removed from the top of the listbox (and the search field cleared):
But the listbox does NOT get updated if the exact same routine is triggered from a click on one of those top three options in listbox itself:
As you can see from the above screenshot, it still shows those three options at the top, even though they are NOT in the array that I assigned to the listbox, as evidenced by the screenshot below:
But as you could see from the earlier screenshot, it shows 7 items in the ListBox instead of the three there actually are. But there are indeed just three items that should be showing in that list box:
? .ListCount
3
? .List(0)
263213: ICT Systems Test Engineer
? .List(1)
263299: ICT Support and Test Engineers nec
? .List(2)
839313: Product Tester
Basically, as soon as I try to update what's in the listbox via a click on the listbox itself, I can't update it.
It doesn't seem to matter if I set focus to something other than the listbox before the filtering code executes, and I've even tried completely clearing the Listbox with .clear. It just doesn't clear, until I manually click on one of those command buttons again.
Anyone have any pointers?
Ah, what an idiot I am for overlooking the painfully obvious solution. The ListBox list happily redraws in response to any event other than the ListBox_Click event, right? So all I needed to do was to use the ListBox_Click event to determine what got clicked (as I currently do), and then use the ListBox_MouseUp event to trigger the actual updating of the ListBox list. Works a treat.
Hopefully this post will save someone else two days of pain in the future. Probably me.

How to replace one records with many (ie explode a group into pieces) when entering?

I am trying to figure out the best approach for something - I have added an additional table to the Sales Order screen as a new tab and it works fine to save records into it. The next thing needed is to potentially explode a value into many lines if it is a certain type. So if they enter a "kit" into my grid/tab - we would want to replace the kit with its components and not have the kit in the grid anymore.
I know how to insert the records etc. My biggest concern is which event to do the work under (field or row level and -ed vs -ing) . I know I could potentially create an endless loop if I don't do it properly.
**edit - I tried using RowInserting - I can cancel the inserting and add my records in there - however it does not trigger the screen to refresh from the cache. If i Save the order - it will display my new rows properly. however, i dont want to do a save in my code. I am also concerned about it triggering another rowinserting.
With rowinserted - it seems to be the same with the screen not refreshing and also i get an error about the row that i deleted.
We had a similar request and what we did is instead of adding the item in grid level and waiting for a trigger, we added a grid tool bar button that pops up a small smart panel to select the kit item, its version and the quantity required. Then we inserted the component lines to the grid with required calculations.

checking if current user is author of the document

I have a formA where I have a field '_author' which is of type Authors/Computed for display with value (#Subset($Updatedby;1)). I display information from formA on viewA. What I want to achieve is that documents that are created by you are only visible to yourself on viewA. I tried the following formula in viewA 'View Selection':
SELECT (form = "formA" & #UserName =_author). Even though I know that these two variables have the same values when I read it from the document's properties, the condition is not satisfied and I do not see a single document. If I delete everything after "&", the view shows all documents.
All is hosted on a server which handles users.
A handy workaround is to create a Page with an embedded view. This view is exactly like your view but has an additional first categorized (!) column with your field _author.
Put into embedded view's property "Show single category" the formula #UserName or #Name([CN]; #UserName) depending on how your categorized column _author is formatted. Show then always the Page instead of the view.
This way you avoid trouble with "Shared, private on first use" views and users see exactly their own documents only.
#UserName works in a special manner in selection formulas in views. In your case the view should be Private on First Use. Read further here: http://www-01.ibm.com/support/docview.wss?uid=swg21089773 .
Be aware that this lead to all sort of issues, e.g. when you update the design of the view users must remove the view manually to get the changes deployed.

Unexpected behaviour in a Lotus Notes programmable table

I'm designing a workflow database in Lotus Notes 6.0.3 (soon upgrading to 8.5), and my OS is Windows XP.
I have recently tried converting a tabbed table into a programmable one. This was so that I could control which tab was displayed to the user when it was opened, so that they were presented with the most appropriate one for that document's progress through the workflow. That part of it works!
One of the tabs features a radio button that controls visibility of the next tab, and a pair of cascading dialogue boxes. One contains the static list "Person":"Team", and the other has a formula based on the first:
view:=#If(PeerReview = "Team"; "GroupNames"; "GroupMembers");
#Unique(#DbColumn(""; ""; view; 1))
The dialogue boxes have the property "Refresh fields on keyword change" selected.
The behaviour that I wasn't expecting is this. If the radio button is set to "Yes" and a value is selected in one of the dialogue boxes, the table opens the next tab. If the radio button is set to "No" and a value is selected in one of the dialogue boxes, the entire table is hidden.
I can duplicate the latter by switching off the "Refresh fields on keyword change" property on the dialogue boxes and instead pressing F9 after selecting a value. I have no idea why the former occurs, though. The table is called "RFCInfo", and I have a field on the form called "$RFCInfo" which is editable, hidden from all users who aren't me and initially set by a Postopen script, which I can post if necessary - it's essentially a Select Case statement that looks at a particular item value and returns the name of the table row relating to that value.
Can anyone offer any pointers?
Hide-when formulas in table cells in Notes R5 and R6 were notorious for breaking in unpredictable ways when you edited the table cells. Even in R7, I think they were still a little bit funky, but by R8 they were finally really solid. You haven't shown the hide-when's but my first guess is that you are simply a victim of the bad behavior.
Please don't shoot the messenger, but the usual way we addressed this sort of problem was to painstakingly re-create the entire table from scratch, and hope we never have to edit it again. I.e., make a copy of the table in a scratch form and clear all the hide-whens -- one by one. Then create a brand new empty table in a second scratch form and get all the cells set up exactly like the original table, including nested tables, merged cells, and other settings -- but skip the hide-whens for now. Then copy each cell's content from the first scratch form to the corresponding cell of the second scratch form. Then, referring to the hide-whens in the original form, re-create each hide-when on the paragraphs in the cells on the second scratch form. Finally, delete the original table from your original form and then copy/paste the table from the second scratch from back into your original form.
Once you have R8.5, move to XPages in Notes, it's almost a no-brainer to implement your tabs. And in return, you get many other interesting issues to solve!

Resources