Jump to content

Getting The Service's Id Within Addservice()


Jamie

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...