Highlighted
Super Contributor.
Super Contributor.
443 views

Event Processor does not run when creating new record. Please Help

Hello

I created an Event Processor that automatically defines a title to new records, but I have noticed that it only works if I drag and drop any electronic document to Records Manager. I can select any type of record for the electronic document and without any problem the automatic change in the title is made.  If I create a new record using the Records Manager New option, the Event Processor does not run. I need that if I create a new folder or document, the event will run and modify the title. How can I get the event to run when I create the new record from the Records Manager menu options?

Thank you,

0 Likes
12 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

I am pretty sure something else is going on, the event processor not getting triggered when you use the menu options sounds very unlikely.

Which event are you monitoring?  Is it an event that gets fired when you drag a document but not when you create a Record from the menu?


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Hi

This is the code I am using for the tests.

namespace TestRM
{
public class TestRM : HP.HPTRIM.SDK.TrimEventProcessorAddIn
{
public override void ProcessEvent(HP.HPTRIM.SDK.Database db, HP.HPTRIM.SDK.TrimEvent eventData)
{
if(eventData.ObjectType == HP.HPTRIM.SDK.BaseObjectTypes.Record)
{
if (eventData.EventType == HP.HPTRIM.SDK.Events.ObjectAdded)
{
HP.HPTRIM.SDK.Record record = db.FindTrimObjectByUri(HP.HPTRIM.SDK.BaseObjectTypes.Record, eventData.ObjectUri) as Record;
string notestring = "Record type " + record.RecordType.Name + "Container " + record.Container.Name + " Container uri " + record.Container.Uri + " event fired";

string titlenew = record.RecordType.Name;
long rec = 0;
TrimMainObjectSearch objSearch = new TrimMainObjectSearch(db, BaseObjectTypes.Record);
objSearch.SetSearchString("Container:" + record.Container.Uri.UriAsString);
rec = objSearch.Count;
notestring = notestring + " Records found " + rec;
// ---------------------------------------------------------------------------------------------
record.SetNotes(notestring, NotesUpdateType.AppendWithUserStamp);
titlenew = titlenew + " " + rec;
record.Title = titlenew;
record.Save();
}
}
}
}
}
Based on your question, I suppose there is a specific event for when I create a record from the menu. Is that so?
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

I thought maybe you were using a document related event.

How about removing the test for the event type and just log which events actually get fired so that you can see whether anything at all is happening when you create the record.

Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Can you give me an idea of how to capture the events? These are my first steps with the SDK and I still don't know all its functionalities.

 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

All I meant was to remove the if  statement below and write a log of all the events that occur so that you can see what (if anything) happens as you create your Record.  If you are using a recent version of CM (9.3 I think) you will also need to look in Enterprise Studio in Configure Events to ensure all events are selected.

 

if (eventData.EventType == HP.HPTRIM.SDK.Events.ObjectAdded)

 


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Thanks David,

I'm going to modify the code and I'll tell you the result. Thank you very much for your help.

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Hi,

These are the events that are generated when I create a record from the menu.

ObjectAdded
CurLocAssigned
HomeAssigned
OwnerAssigned
ContentAdded
DateLastActionChanged
ObjectAdded
ContainerChanged
CurLocAssigned
HomeAssigned
OwnerAssigned
ContentAdded
DateLastActionChanged
ObjectAdded
ContainerChanged
CurLocAssigned
HomeAssigned
OwnerAssigned
ContentAdded
DateLastActionChanged
ObjectAdded
ContainerChanged
CurLocAssigned
HomeAssigned
OwnerAssigned
ContentAdded
DateLastActionChanged
ObjectAdded
ContainerChanged
CurLocAssigned
HomeAssigned
OwnerAssigned

These are the events that are generated when I create a record by dragging a file

ContentAdded
DateLastActionChanged
ObjectAdded
ContainerChanged
DocAttached
CurLocAssigned
HomeAssigned
OwnerAssigned

 

 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

To clarify the log files.The creation from the menu is a folder with automatic subfolders. The second log is from a file dragged to a folder.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

So, the event processor is running and the event you were testing for (ObjectAdded) in your if statement is sent.

Does this mean it is working, or have I overlooked something?

Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Highlighted
Super Contributor.
Super Contributor.

It actually works if I remove the validations.

I need you to make changes to the title of the created record and the notes if the record is a folder. To do this using these instructions

HP.HPTRIM.SDK.Record record = db.FindTrimObjectByUri (HP.HPTRIM.SDK.BaseObjectTypes.Record, eventData.ObjectUri) as Record;

if (System.Convert.ToInt32 (record.RecordType) == 1)

{

}

But when I include these instructions it does not make any change in the title. If I delete it, make the changes. What am I doing wrong?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

The line below looks odd. If you are validating that the RecordType URI == 1 then you should test the Uri property. Also converting to Int32 will not be a happy thing as the Uri is a long (Int64).

*** My Code ***
if (record.RecordType.Uri == 1)


*** Your code ***
if (System.Convert.ToInt32 (record.RecordType) == 1)



Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.