I’m trying to add custom ajax code for some custom fields. Basically, my goal is to let the user enter an order number into a custom field. Ajax will then send the value that was entered, using onChange, to a handler file. This file will submit an API request to an internal service which will return customer and other information about the order. Finally, the handler will package up the information using JSON, and send it back. The success handler in the ajax request will set the values of some other custom fields using the data from the JSON. With an order number, the user gets several fields filled in.
So far, I can submit the request. I’ve modified a local copy of html/Elements/EditCustomFieldFreeForm, using Perl to check the ID of the field being modified. If it’s equal to the ID of the field I want to give this extra functionality to, I make a request to local/html/Helpers/ajax/CFHandler.pm. This is where the problem is.
CFHandler.pm started as a Perl file, but today, I tried to use Mason syntax instead. No luck either way. For now, I just want to log something to the RT log, to be sure the file is being executed. I’ve not been able to do this. I’ve tried a bunch of approaches, but I don’t know enough about RT’s templates to know what I’m doing wrong. It could also be that EditCustomFieldFreeForm doesn’t appear to have access to RT->Config, so I can’t get the WebPath setting to properly set the URL. When I alert this value, it’s always blank.
- Where does RT come from? Many templates have a variable called RT, which lets them access the logger, configuration, and other critical variables. How do they get it?
- Does RT have a better way to do what I’m trying to do? I know I could use scrips on ticket creation or modification, but I’m told that doing that isn’t a great option. Users can’t see the values that are auto-filled until after the changes are complete; my boss wants the changes to appear in real time, so users can catch mistakes. Scrips would be a whole lot easier, but I’m told to try to get ajax working first.
- Is there documentation for customizing ajax? It’s possible to customize a lot about RT, and the wiki has some good information that’s not in the official documentation, but I’ve never fond anything about ajax.
Thanks for any help or suggestions anyone has.