Skip to main content

Get AdminService in Template code

Comments

9 comments

  • Zendesk API User
    Author: a_reg - 8/4/2014 11:06

    Hola Rodrigo,

    i think it's just a syntax problem. In templates you can go like this (the bold part):

    $CMS_SET(setProject, #global.project)$

    $-- get current connection (at this point the setProject variable has been correctly set)--$

    $CMS_SET(connection, setProject.getUserService().getConnection())$ 

    $-- get specialist broker and the admin service --$

    $CMS_SET(adminService, connection.getService(class("de.espirit.firstspirit.access.AdminService")))$ 

    $-- get Scheduled entry --$

    $CMS_SET(scheduleEntry, adminService.getScheduleStorage().getScheduleEntry(5779891))$

    0
  • Zendesk API User
    Author: pinarodrigo - 8/4/2014 14:51

    Hola Andreas,

    thank you for your answer.

    I kindda had already tried that (although not with the call to the "class()" function), but the result is the same, the "$CMS_SET(adminService, connection.getService(class("de.espirit.firstspirit.access.AdminService")))$" function evaluates to :

    de.espirit.firstspirit.parser.eval.Undefined

    And the generation error is the same:

    ERROR ($CMS_SET(setAdminService, setBroker.requireSpecialist(ServicesBroker.TYPE).getService(class("de.espirit.firstspirit.access.AdminService")))$ at 14, 2): No specialist found for 'null'!

    Any Ideas?

    0
  • Zendesk API User
    Author: daniel_philippi - 8/4/2014 15:03

    Hallo Rodrigo.

    Simply use getAdminService() on the connection object.

    It works fine for me.

    Greetings,

    Daniel

    0
  • Zendesk API User
    Author: pinarodrigo - 8/4/2014 15:08

    Hola Daniel,

    are you under FS51, also?, I believe that function is deprecated now.

    I was actually using "getAdminService" before but that implementation doesn't work anymore.

    Saludos"

    0
  • Zendesk API User
    Author: daniel_philippi - 8/4/2014 15:31

    Holla Rodrigo.

    You are right, it's deprecated. We used it in a scheduler script and there you can do an import, so this one works:

    import de.espirit.firstspirit.access.AdminService;

    AdminService as = connection.getService(AdminService.class));

    If I try the solution the .getService(class("de.espirit.firstspirit.access.AdminService")) in a template it's also not working for me.

    Daniel

    0
  • Zendesk API User
    Author: mbergmann - 8/4/2014 20:44

    Hello Rodrigo,

    you simply cannot use classes "directly" like in pure Java. You have also to use class("...") in the first part inside requireSpecialist: .requireSpecialist(class("de.espirit....ServicesBroker").TYPE)...

    The reason for the error message is that FirstSpirit tries to access a VARIABLE named ServicesBroker (which of course does not exist and therefore is null).

    Michael

    0
  • Zendesk API User
    Author: a_reg - 8/5/2014 8:27

    Hola Rodrigo,

    like Daniel said, working directly on the connection object works fine (for me), just use the

    '.getService(class("de.espirit.firstspirit.access.AdminService"))' instead of 'getAdminService()'.

    If you go wtih requireSpecialist(..), then you have to use the class('..') syntax there as well, like Michael said.

    Andreas

    0
  • Zendesk API User
    Author: pinarodrigo - 8/5/2014 12:29

    Hello Michael,

    Thank you for your helpful reply, using the (operator?) class() on both methods gives us the expected results.

    One last question, could you point me to the place where this operator is documented?

    Thank you.

    0
  • Zendesk API User
    Author: pinarodrigo - 8/5/2014 12:31

    Thank you, Andreas.

    Michael's suggestion works, I was just wondering where is this class() operator documented; do you by any chance, know where?

    Saludos!

    0

Please sign in to leave a comment.