Jump to content

Getting The Service's Id Within Addservice()


Recommended Posts

Posted (edited)

Hello,

 

I am in the process of creating a Module and I am in need of getting the newly created service's ID within the addService function.

 

The ID I am after is the ending ID on this URL:

admin/clients/editservice/2/5/

Obviously the `2` represents the client and the `5` represents the service's ID.

 

Is it possible to get the `5` within the addService() function inside a Module? Or would I have to calculate it myself (As I am guessing that the service is created after addService())?

 

Any advice would be really appreciated.

 

Regards,

 

Jamie

 

Edit: Accidentally put 'addPackage()' instead of 'AddService()'; Ops! 

Edited by Jamie
Posted

As you guessed, the service ID is not available to Module::addService because it is unknown until after that method call, and would only be created if no errors were encountered.

 

What are you trying to use it for?

 

You might be able to create a plugin that checks the addService event handler, and use that to determine the service ID after the service has been created.

Posted

I am attempting to create a module for TCAdmin.

 

TCAdmin uses the billing ID as a reference (It also uses the billing ID as the main ID to reference a service) and instead of creating a whole new lot of IDs that don't match Blesta's services IDs, I thought it would be more effective if the service ID matched the billing ID.

 

I appreciate you comment and I'll have a little play around and see what I can come up with.

 

Thanks alot :)

Posted

I think most APIs have their own reference ID, and most modules simply store and use that ID where necessary. I don't think you need to go out of your way to match them to service IDs in Blesta. That ID should be a back-end ID anyway, which no one would see (except admins, if you allowed them to add an existing TCAdmin account into Blesta without provisioning it).

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...