[Rt-devel] duplicating a scrip in code

Todd Chapman todd at chaka.net
Thu Jan 5 00:28:19 EST 2006


On Thu, Jan 05, 2006 at 04:17:34PM +1100, Jens Porup wrote:
> 
> Here's a poser for you.
> 
> I have a Scrip/Template combo that creates a ticket.
> 
> Now I want to duplicate that code in custom code.
> 
> I could try to duplicate that as $Ticket->Create() code,
> but as soon as I start looking for the Parent and DependsOn
> params (which don't seem to be there!) I hit a wall.
> 
> Then I think why can't I just load the already existing
> Scrip and Template, and execute them? This would prevent
> any discrepancy creeping in between the coded action and
> the scrip.
> 
> But.... how do I do this? I see the $Scrip->Apply() method,
> but there's no $Scrip->Load() method.
> 
> So how do I bring up the scrip I want, so that I can then
> execute it?
> 
> Suggestions or other ways of looking at this most appreciated.
> 
> Thanks,
> 
> Jens

Normally a transaction triggers a scrip, so I would look at
the Transaction code (probably the Create method) and see
how it loads and runs a scrip. This may not work though
because a scrip may expect to run in the context of a
transaction.

It would be better to write the code to do what you want
and then have the scrip call that code. That avoids the
duplication problem.

-Todd


More information about the Rt-devel mailing list