How to triger an event only if certain node condition is met? - cypher

I know that I can use the following code to do some action right after the node is created:
CREATE TRIGGER createVertex
ON () CREATE AFTER COMMIT EXECUTE
UNWIND createdVertices AS createdVertex
SET createdVertex.created = timestamp()
But is it possible to run a trigger only if certain criteria are met, e.g. if a new node has a relationship to some other node?
I have a node person that is connected to a city, and I want to add a timestamp to it only if the city name is London. How can I do that?

Related

sql trigger -> where did it get triggered from?

We have an sql-table with products in it.
We need to know how a certain column is mutated, since we made this impossible but it still does get changed.
So say product 'APPLETREE' is once created with length 3 mtr.
This 3 mtr may never be changed. And still sometimes it does get!
To find out why we created a trigger on table products to write a log-file with columns
productnr , oldlength value, newlength value, date, time, user.
This all works fine. We get the info.
But preferably we would also know where the trigger got fired from (which stored procedure or sql job)
Is there a way to get the 'path' from which te trigger was fired ?
I could not find documentation about this

Get ID of inserted record then update another table

Information
I am currently migrating legacy data from an old database to a new database, where the schema has changed.
Old Schema
Table Event
PK_EventID
View OldVideoConferenceParticiants
FK_EventID
FK_ParticipantID
New Schema
Table Event
PK_EventID
FK_VideoConferenceID
Table VideoConference
PK_VideoConferenceID
Table VideoConferenceParticipants
PK_VideoConferenceParticipantID
FK_VideoConferenceID
What I want to do, is:
Group all old participants based on their eventID. (done)
For each eventID, insert a new VideoConference and then set the VideoConference FK for each event to their respective newly inserted VideoConferenceID. (I can't figure this one out)
For each old participant, get the corresponding VideoConferenceID and create a new VideoConferenceParticipant. (done)
Problem
I think I might need to use MERGE but all of my attemps thus far have been disastrous. I've also tried using
INSERT ... OUPUT INSERTED.VideconferenceID
...but I can't get it right. I need to have both the EventID and the VideoConferenceID side by side somehow, which insert does not allow me to do.
Could someone please give me some guidance on how to accomplish #2 above?

Xrm.Page.ui.getFormType() returns 2 when create order from quote

When i am creating an order from quote, in onload Xrm.Page.ui.getFormType() returns me the value 2.
but the form is in create mode, so should return 1.
When you "win" a quote and a Sales Order is generated, there is no Create state presented by the UI - the system creates the new record in the background and then displays it. When you are presented with the new Sales Order through this process, it already has a record ID so Xrm.Page.ui.getFormType() will return 2, which is the Update state.
The only way to get the Create state (1) from Xrm.Page.ui.getFormType() would be to manually create a Sales Order. However, if you do this you will lose much of the convenience the system does automatically for you, such as copying over all fields with the same name (essentially duplicating the Quote data into the the new Sales Order).

Set value dynamic action not working in apex

I have a problem creating sql dynamic action in oracle apex v4.2. I have two fields, Department number and department name. Department number is a text field with autocomplete. The department name is a display field. On changing the department number, the department name should be displayed by an sql query.
I created a set value dynamic action on department number, giving the correct values in page item to submit and the correct sql query referencing P3_DEPARTMENT_NO.
When i run the page, after select a department number, the department name is not coming up automatically.
Could you please suggest on what i might be missing.
Thanks in advance.
You can try use this way:
First step: In the Shared Components -> Application Processes: create a process myProcess an put your sql dynamic in.
Second step: Create a javascript function myFunction to call the process myProcess.
Third step: Use onChange event to call your javascript function myFunction.
Also you can find a lot of exemples on Denes Kubicek app: https://apex.oracle.com/pls/otn/f?p=31517:101:116042570427567.
Best regards,
iulian
The exact behaviour of autocomplete lists is probably browser dependent, but generally speaking, don't rely on the "Change" event, as it won't necessarily fire when you select from the list.
You'll need to experiment to get the behaviour you want in your particular situation, but as a starting point you might want to try replacing the "Change" event type on your dynamic action with "Lose focus". That way the dynamic action should always be triggered when you tab or click away from P3_DEPARTMENT_NO.
In similar situations in the past, I've used "Key release" instead of "Lose focus", and I've created a second dynamic action which does the same thing, but triggered by "Get focus". That combination ensures that the display field stays synchronised with the user's selection, whether a value is keyed in or selected from the autocomplete list. Whether or not you go this route depends on how happy you are about the database being hit with your department name query every time a user interacts with P3_DEPARTMENT_NO in any way.

how does upsert with external id work?

How does upsert work in the Salesforce API?
I believe that it checks it checks if there is a record with unique id. In the case that it is available, then it updates the record otherwise the record is created.
Is this correct?
I am receiving the following error
Upsert failed. First exception on row 1; first error: DUPLICATE_EXTERNAL_ID, Asset Tag: more than one record found for external id field: [a11M0000000CwJqIAK, a11M0000000CwJvIAK]: [Asset_Tag__c]
I have a list with items, and there are no duplicate Asset_Tag values.
system.debug('LstItem Asset_Tag__c'+LstItem );
upsert LstItem Asset_Tag__c;
From the debug log
LstItem Asset_Tag__c(Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=12149, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 06:08:47}, Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=23157, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 08:26:14})
What can I do to resolve this issue?
The error message indicates that, based on the External Id value you provided, there were two matching records. In this case, the system does not know which one it should update, so it fails.
If you take a look at /a11M0000000CwJqIAK and /a11M0000000CwJvIAK, they will have the same value in the external ID field. You may want to consider de-duplicating the records for this object.