How can I create a new user-defined event (call it "UE") from within my plugin and then create a new alarm definition that is triggered whenever "UE" is triggered?

I have a plugin whose Background part is running in the Event Server. And has a Management Client UI too.

On server startup, I want to check whether a user-defined and an alarm definition exists or not (based on name, guid etc)…and if they don’t I want to create them automatically from within the plugin in such a way that the new alarm definition is triggered whenever the user-defined event is triggered.

Right now I have:

ServerId sid = EnvironmentManager.Instance.CurrentSite.ServerId;
            Item i = new Item(sid, sid.Id, new Guid("a6b60fbc-879b-4d8d-a339-2c2e4a47b3f2"), "My User-defined Event", FolderType.No, Kind.InputEvent);
 
// a6b60fbc-879b-4d8d-a339-2c2e4a47b3f2 is a fresh generated Guid
 
Configuration.Instance.SaveItemConfiguration(CalipsaMilestonePluginDefinition.CalipsaMilestonePluginPluginId, i);

This doesn’t crash but it doesn’t work either, which is expected since I don’t have much of an idea how to create new items :slight_smile:

Would appreciate some help with this.

Thank you.

Please explore Configuration API Client -

https://doc.developer.milestonesys.com/html/index.html?base=samples/configapiclient.html&tree=tree_2.html

Thanks.

I’ve looked at the ConfigApi sample code, though not too deeply, and I could be wrong but I think it requires a token-based login first.

I was wondering if this could be done from within a plugin integration without any login_,_ say, the code runs in the Management Client or in the background in Event Server.

Using the following code I was able to make one change, unintended of course. It renamed the site.

ServerId currentServerId = EnvironmentManager.Instance.CurrentSite.ServerId;
                Guid pluginId = CalipsaMilestonePluginDefinition.CalipsaMilestonePluginPluginId;
                
                UserDefinedEvent receivingUE = new UserDefinedEvent(currentServerId, "/");
                
                receivingUE.Name = Constants.calipsaReceivingEvent;
                receivingUE.Description = Constants.calipsaReceivingEvent;
                receivingUE.Save();

Yes.

Is there a way to create a User-defined or Analytics Event from within the plugin (background running in the Event Server)?

I’m guessing if the site’s name can be changed from within then perhaps new events can be created too?

Of course, I’d need a uniqueness check on the event’s name so that duplicates are not created.

It is possible to use ConfigAPI Client code for creating a User-defined or Analytics Event from within the plugin. It is easy to use the strongly typed classes. Try this snippet of code:

private void createUserDefEvent()
{
    var ms = new ManagementServer(EnvironmentManager.Instance.CurrentSite);
    var udefolder = ms.UserDefinedEventFolder;
    udefolder.AddUserDefinedEvent("testingWithConfig");
}

Yeah I found almost the same snippet from another answer to another old post. It worked. Thanks.