Menu

Unable to add FunctionalCI objects to Ticket via Process

Markus
2021-07-02
2021-07-05
  • Markus

    Markus - 2021-07-02

    Dear All,

    I implemented a iBackgroundProcess to enrich existing Tickets with additional information.

    Changing simple attributes works like a charm and I'm able to add contacts.

    However, when I try to use the same way I use for contacts, to add Objects derived from FunctionalCI, it does not work, and I do not have any idea where the problem lies.

    This is my code:

    $tickets = new DBObjectSet(DBObjectSearch::FromOQL('SELECT Ticket WHERE customer_ticket = \'\''));
    while ($ticket = $tickets->Fetch()) {
    
        // Get current functionalcis
        $oCIsSet = $ticket->Get('functionalcis_list');
    
        // Get related cis
        $cis = new DBObjectSet(DBObjectSearch::FromOQL('SELECT Branch AS B WHERE B.outlet_id=\'210905\''));
        while ($ci = $cis->Fetch()) {
            $oNewLink = new lnkFunctionalCIToTicket();
            $oNewLink->Set('functionalci_id', $ci);
            $oNewLink->Set('impact_code', 'computed');
            $oCIsSet->AddItem($oNewLink);
        }
        $ticket->Set('functionalcis_list', $oCIsSet);
    
        // Persist ticket
        $ticket->DBWrite();
    }
    

    Both OQL queries are mock queries, but they do return what I expect.

    I use a similar approach to add contacts and this works without problem.

    Not sure what's going on.

    Branch is a class I wrote myself, it's derived from ApplicationSolution which itself is derived from FunctionalCI so I expect that I should be able to add Branch objects to CIs of a ticket.

    Adding them via the web GUI works.

    Any help or pointes in the right directions are appreciated.

    All the best,
    Markus

     

    Last edit: Markus 2021-07-02
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2021-07-02

    I'd go for both setting the functionalci_id and ticket_id; then use $oNewLink->DBInsert()

     
    • Markus

      Markus - 2021-07-05

      Thanks a lot Jeffrey!

      This was a rather easy and straight forward solution that I did not think of :(.

      Just need to modify my code a bit to avoid duplication, otherwise this should be fine now.

      Thanks again!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.