Siebel - Change in MVG data in child BC alters MVG data in Parent - siebel

I have an MVG applet present in Parent and child BusComp. MVG Data is entered in parent and when a child record is created, the MVG data is populated into the child BC MVG.
This is causing an issue; if a user modifies the MVG data in child BC, the data in parent MVG is also altered. What is the best way to prevent this.
Both MVGs are based on the same BusComp.
Siebel Version : 8.1

Are the parent and child BCs also on same tables ? It could be that records added from parent are showing up in child. You could add one more column as a 'Type' column, and predefault with different values for parent and child. Then put a bc search spec on the MVG BC/Applet to filter out corresponding records.
Or..if you are using XM tables for the MVGs, you could change the value in Name or Type columns.

If your MVG is not based on an XM table, consider the following.
Since some MVGs (like Account Contacts for example) are based on an intersection table between the parent and child records with joins to both the parent and child tables, then it would be expected behaviour that if you change values on the child table, these changes will then be seen from the parent through the MVG.

Through Script we can fetch the MVG record details and create New record setting the values fetched. Disassociate/delete the old reference from Intertable.
This will ensure that the parent BC MVG data is unaltered while only the Child BC MVG is modified
Although this will cause duplication in the master data, it was accepted in my scenario.

Related

Interactive Grid: Column Filter disappears for columns having value in Cascading LOV Parent Column

I have a child column and depends on a parent column value, filter/sort options are not available for the child column.
I'm facing similar issue posted on https://community.oracle.com/tech/developers/discussion/4313940/interactive-grid-column-filter-disappears-for-columns-having-value-in-cascading-lov-parent-column-s
I see the thread is closed as intended behavior. As a workaround, I tried creating two page items (LOV's) for parent & child and changed my IG query to include where condition based on the page items. So users can filter the data by page items. However that doesn't work either.
Does that mean there is no way to filter/sort the child items on IG?

Google Datastore: how to retrieve entities with children?

I only found the way to get children entities by parent one.
But is there any way to retrieve the list of parent entities (by some parent entity's properties filter) with their children in single call?
(Pseudo query):
SELECT * FROM parents (with children) WHERE parent.property1=...
Result should be like this:
- (parent1, child1, child2)
- (parent2, child3, child4)
....
This is not possible if you store the parents and children as separate entities. However, if the children for a parent is expected to be small, then you can consider storing them as embedded struct slice. Then as you query the parent entities and retrieve them you will have access to their children.
The short answer is no.
Some background
Entities in a Datastore mode database form an ancestor path, which means a hierarchically structured space, similar to the directory structure of a file system.
Workarounds:
Depending on your needs there are a couple things that you could do:
You could retrieve each parent and their children individually in multiple calls and then combine all the parts together.
You could use Special query types, such as kindless queries, which is a query with no kind and no ancestor filter that retrieves all of the entities of an application from Datastore, so you can gather the needed information.
Not sure this qualifies as an answer but I have the same scenario and below are the two options I am considering.
The scenario I am in is an Employer kind and an Employee kind. The Employee is a child of Employer but the same Employee can be part of multiple Employers.
I need to find all Employers a specific Employee is part of.
Option 1 (the one I think I will go with)
Have a third entity for a reverse lookup. The key will be the Employee's last part of the key with an additional property to hold the list of Employers' keys.
Every time an Employer/Employee relationship changes I will also update the reverse lookup kind.
Option 2
Have the last part of the Employee's key saved separately in the same entity as an indexed property so that I can search by it (and then able to find each of those entities' parent key).

Update of QTreeView without changing selection

I have a model that retrieves data from a table in a database from a certain SQL query, and shows the items in a QTreeView. The characteristics are:
the data comes from a table, but has an underlying tree structure (some rows are parents that have rows below them as children)
this tree structure is shown in the QTreeView
the children are selectable in the QTreeView (not so the parents)
the table in the database gets updated continuously
in the updates, a children can be added to any existing parent
periodically (with a QTimer) the QTreeView is updated with the contents of the table
Since the children are added at any time to any parent, the first silly approach when updating the QTreeView is clearing it all, and append all the rows again, in form of parent or children, to the QTreeView. This is a 0-order approximation, and it is indeed terrible inefficient. In particular, the following problems appear:
Any existing selection is gone
Any expanded parent showing its children is collapsed (unless ExpandAll is active)
The view is reset to show the very first row.
What is the best solution to this problem? I mean, the first solution I will try will be not to clear the QTreeView, but instead parse all the returned rows from the table, and check for each of them whether the corresponding item in the QTreeView exists, and add it if not. But I wonder if there is a trickiest solution to engage a given table in a database with a QTreeView (I know this exists for a QTableView, but then the tree structure is gone).
This thread mentions a general approach, but this might get tricky quickly, but I am not sure how this would work if the underlying model is changing constantly (i.e. the QModelIndex becoming invalid).
Worst case is that you will have to write your own mechanism to remember the selection before updating and then re-applying it.
I assume you use some model/view implementation? You could enhance your model with a safe selection handling, in case the example mentioned above does not work for you.
I guess this is the case for a self-answer.
As I presumed, after a careful analysis of what data is retrieved from the database, I had to do the following "upgrades" to the retrieval code:
I retrieve, along with the fields I want to show in the view, two identifiers, one for grouping rows and one for sorting items into groups
I also retrieve the internal record ID (an increasing integer number) from the table in the database, in order to ask only for new records in the next retrieval.
In the model population code, I added the following:
I first scan the initial records that may belong to existing groups in the model
When, in the scanning, I reach the last group in the model, this implies that the rest of retrieved records belong to new groups (remember the records are retrieved sorted such that items that belong to the same group are retrieved together)
Then start creating groups and adding items to each group, until we use all the records retrieved.
Finally, it is very important:
the use beginInsertRows() and endInsertRows() before and after inserting new items in the model
capture the sorting status of the view (with sortIndicatorSection() and sortIndicatorOrder()) and re-apply this sorting status after updating the model (with sortByColumn())
Doing that the current position and selection in the QTreeView receiving the model updates are preserved, and the items in the view are added and the view updated transparently for the user.

How to access another field/combo in the rowedittemplate during creation of a grid row when selectionChanged or checkValue happens?

The situation is as follows :
I am creating a row in the grid. I have several properties among which are one combo called 'department' and one field called 'name'. The business rule is that all the 'names' in a 'department' must be unique. The grid does not load all the department-name combinations so I have to make a call to the back-end. I want to make this call when
selectionChanged on the 'department' combo happens or
when 'checkValue' of the validator options of the 'name' filed happens.
This way I check when either changes. The problem is that this happens during creation and there are no rows in the datasource and no accumulated rows in the transaction log.
How can I access the fields of the 'rowEditTemplate' during creation during these particular events in order to check my values? Is there any other/better way to achieve this?
The editors are not created until you do the first edit. You could use the editRowStarted event to attach your editors logic. They are obtainable using the editorForKey method.
editRowStarted: function (evt, ui) {
var comboEditor = ui.owner.editorForKey("ProductDescription");
}
I created a small fiddle that assigns a data source for the combo on editRowStarted. It should work as a starting point for what you are trying to achieve.
http://jsfiddle.net/hfen0qea/

How to maintain a link between parent QStandardItems and database row ids in a tree model?

I have a little problem I am trying to figure out, I am working on a QT app that is using the QTreeView and I have a bunch of categories which have children, so they look like
Parent 1
Parent 2
- Child 1
- Child 2
Parent 3
and so on and so forth, so in my database I have rows which have all the regular details (name, id, date created, etc) and the ones which are children have their parent specified (so pid=parent row id). I then loop over then using the standard QSqlQuery stuff. But the problem I am running into is this...
Items are added to the treeview by QStandardItem* item = new QStandardItem(icon, name); and then appending the row model->appendRow(item); but my children need to call parentitem->appendRow(item); so the QStandardItem* item of the parent. But how can I find out what that is without storing every single item?
Moral of the story is, is there a way to do one of the following that won't destroy performance.
Store the QStandardItem* item in an array that I could reference the parent in the childs loop?
Assign an ID or something to QStandardItem* item which I could then reference when adding a child.
Generate a TreeView model from an array, where the children array elements get added as children?
Something else I haven't thought of...
I can't seem to find any good examples of QTreeView with children from a database.
All you need is a QMap<int, QStandardItem*> rowItemMap. When you retrieve a row from the database with a given row id, you immediately create an item and add it to the map. You then add it to a parent that you look up in the map. You'll need to create a dummy parent as the root item. There's nothing wrong with storing pointers to items. For reasonable amounts of items, it won't matter. If you think of storing more than 10k items, you may want to think of using a view that offers transitive closure up to a certain depth of the tree. It'd then be much easier to map such a view, via QSqlTableModel, directly onto the tree, without having to copy the entire tree from the database into a temporary model.